Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-04-2009, 08:19 AM   #1
Registered: Jun 2007
Distribution: Slackware, Gentoo, Debian
Posts: 36

Rep: Reputation: 16
ANSI C: force malloc to return address with specific range.

Hi everyone,

I'm looking for a way to force malloc() to return address in a specific range (say 0x80000 or something else), in addition I need a way to mask the addresses returned from malloc to be divided by 32.

Anyone got any idea how to do it?

Thanks for your help.
Old 01-04-2009, 08:29 AM   #2
LQ Newbie
Registered: Jan 2009
Posts: 4

Rep: Reputation: 0
You can not do this using ansi C. You could try using mmap.
Old 01-04-2009, 03:14 PM   #3
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You may write your own wrapper to malloc. Inside simply malloc more (+32 octets for instance) and return the pointer that fits the goal. You'll have your own free(), calloc() and other stuff if you use it.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting by date a specific range of files nooks12 Linux - Newbie 2 01-08-2008 02:45 PM
Script to force resolution/hertz range loadedmind Red Hat 6 03-07-2006 04:32 PM
Samba force user, group doesn't return expected results tisource Linux - Software 1 12-13-2005 12:07 AM
does two malloc statements return same address? hetzme Programming 5 08-16-2005 10:22 AM
why malloc() return different pointer value? hddd Programming 1 05-23-2005 03:38 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration