Mail Archives: djgpp/1996/07/15/13:37:10
Hello all,
I am wanting to know how to use sbrk() for the purpose of experimenting
with my own version of malloc(). The documentation of djgpp shows how to
allocate a block of memory with sbrk(), but does not really explain the behavior
of the function.
What I want to know is:
1. What kind of memory alignment can I expect from sbrk() if any?
2. Can I expect the memory areas allocated by sbrk() to be consecutive or
not? For example, if I allocate 1024 bytes and sbrk() returns an address of
0x10000, would the next call to sbrk() return an address of 0x10400 or could it
return some other address?
3. I have noticed that there is a crt0 flag that can select a unixy sbrk()
algorythm. What does that mean, and how is that different from the default
algorythm? Would that affect in any way the use of sbrk()?
4. Regarding CWSDPMI.EXE, a patch for it was discussed some time back for
it (which I downloaded) which increases it's heap which keeps track of, among
other things, the memory zones that a program uses. How does this relate to the
use of sbrk()? Does the DPMI providor have to keep track of every memory
allocation of your program, thus the more one uses sbrk(), the more the DPMI
provider has to keep track of? Thus should I minimize the number of calls to
sbrk() in a program? And why would the DPMI provider have to keep track of
every memory allocation?
5. Is there any way to return some of the memory to the DPMI provider that
has already been allocated? If so, how?
I thank you for any information that can be provided about sbrk().
Please refer all replies back to my E-mail address, as I sometimes seem to
miss part of the newsgroup. Troy........ 74617 DOT 365 AT compuserve DOT com
- Raw text -