Date: Wed, 3 Nov 1999 09:55:14 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Steve cc: djgpp AT delorie DOT com Subject: Re: Standard Library In-Reply-To: <941558204.23499.0.nnrp-08.d4e443d2@news.demon.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Tue, 2 Nov 1999, Steve wrote: > Firstly, how do you make use of the size information within 'malloc' and > 'free', when this is held locally and other functions do not has scope > access to these variables. That's not what I meant. What I meant is that `malloc' stores the info immediately preceding and following the buffer whose pointer it hands back to you. By accessing these hidden fields of the buffer returned by `malloc', you can get at the info. For example, the following code snippet reconstructs the BLOCK structure which holds the information about the allocated buffer: char *ptr = malloc (1000); ... BLOCK *block = (BLOCK *)(ptr - 4); Now you can, for example, get the block size like this: size_t block_size = block->size; As I said, reading the source of malloc in djlsr202.zip will show you this and other details of the info stored by malloc in the buffer that it returns. > Secondly, where can I find the source and binaries for the heap debugging > libraries that you mentioned They are on the usual DJGPP sites on SimTel.NET mirrors, in the v2tk directory.