Mail Archives: djgpp/1998/08/30/10:55:51
On Fri, 28 Aug 1998, Klaus Petzold wrote:
> I tried to write a function, which finds out the size of the largest
> block I can allocate on the heap. On my system it gives back
> 33558524 bytes, but with "char* ptr = (char *)malloc(size);" it
> is possible to allocate 67112956 bytes. Has anyone an idea why
> maxheapblock() fails?
I suggest to read chapter 15 in general, and sections 15.2 and 15.4 in
particular, from the DJGPP FAQ list, before you plunge into this mess.
Several subtle points are explained there.
> do
> {
> memsize += adder;
>
> cptr = (char *)malloc(memsize);
> free(cptr);
> } while (cptr);
`malloc' adds some overhead to the size you request, and then rounds it
up to the next integral power of 2. So you actually ask the DPMI server
for much more than you intend to.
- Raw text -