I was thinking about how the Linux kernel implements system calls and I was wondering if someone could give me a high level view of how sbrk/brk work?
I've reviewed the kernel code, but there is just so much of it and I don't understand it. I was hoping for a summary from someone?
...
I wrote a reasonably basic memory allocator using sbrk. I ask for a chunk of memory, say 65k and carve it up as needed for variables requesting dynamic memory. I free the memory by adding it back to the 65k block. The 65k block is derived from a union sizeof(16-bytes). Then I align the block along an even 16-byte boundary. But I'm gettin...
Hi, the following is a very very simple version of malloc() and seems to allocate some space to me, but apart from the fact that there is no free() and I don't check if I've overrun the allocated space, how can I check that the code is correct?
Any obvious blunders that "C" experts would slap me for?
#include <stdio.h>
#include <unistd...
I have a custom allocator function which uses sbrk() to obtain memory.
How do I release this memory when it's no longer needed?
Is there a function equivalent to free() for malloc() ?
or do I have to use brk() to set the end of the data segment ?
...
Where can I read about sbrk() in some detail?
How does it exactly work?
In what situations would I want to use sbrk() instead of the cumbersome malloc() and new()?
btw, what is the expansion for sbrk()?
...
I would like to dynamically allocate memory from an assembly
program that does not link against the standard C library.
Since brk(2) and sbrk(2) are unavailable on Mac OS X (10.6.2),
what are the alternatives?
(I'm guessing that it involves a Mach call, but there seems to
be little documentation around that)
...
Can anyone explain how malloc() works internally?
I have sometimes done strace program and I see a lot of sbrk system calls, doing man sbrk talks about it being used in malloc() but not much more.
I'd really like to learn how malloc() works.
Thanks, Boda Cydo.
...