Date: Sun, 30 Aug 1998 17:55:07 +0300 (IDT) From: Eli Zaretskii To: Klaus Petzold cc: djgpp AT delorie DOT com Subject: Re: Strange results with own maxheapblock()-function In-Reply-To: <35e71d68.66941@news.space.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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.