Discussion Locked

C: Memory allocation function

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Is there a memory allocation function in ANSI C that would allow the programmer to suggest where in memory to write?

3 replies

by clarkmk

There is no form of malloc() which allows you to specify where to write in memory. Dynamic memory allocation to the heap is managed by algorithms in the operating system, and may vary by OS.

If you want to specify direct writes to specified memory addresses, you will need to have detailed knowlege of the memory allocation methods used by your operating system. Otherwise you could clobber executable code or data, which would be bad.

This discussion is closed to new replies.