LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 01-04-2009, 09:19 AM   #1
Neuzen
Member
 
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.
Neuzen.
 
Old 01-04-2009, 09:29 AM   #2
foobar
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, 04:14 PM   #3
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,539

Rep: Reputation: 149Reputation: 149
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.
 
  


Reply

Tags
malloc


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 03:45 PM
Script to force resolution/hertz range loadedmind Red Hat 6 03-07-2006 05:32 PM
Samba force user, group doesn't return expected results tisource Linux - Software 1 12-13-2005 01:07 AM
does two malloc statements return same address? hetzme Programming 5 08-16-2005 11:22 AM
why malloc() return different pointer value? hddd Programming 1 05-23-2005 04:38 AM


All times are GMT -5. The time now is 11:39 AM.

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