delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/24/06:32:14

From: "Aleksey Kondratyev" <akondra AT no-spam-mv DOT ru>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: free()
Date: Wed, 24 Jun 1998 14:10:51 +0400
Organization: Middle Volga Communication service
Lines: 27
Message-ID: <6mqjja$p9s$1@simtel.ru>
References: <19980623 DOT 131350 DOT 7759 DOT 0 DOT zixyer AT juno DOT com>
Reply-To: "Aleksey Kondratyev" <djgpp AT delorie DOT com>
NNTP-Posting-Host: ppp13.usr.mv.ru
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>How does free() know how much memory to return to the heap?  Does it have
>to be the originally malloc()ed pointer or can it be a different pointer
>to the memory that was allocated?  I'm writing a linked list and keeping
>pointers to each element around kinda defeats the purpose...  thanks in
>advance for any help
>

One possible heap implementation approach could be the following:
heap manager holds a list based structure of allocated blocks and malloc
returns a pointer to a data record of a heap block description structure
which includes block size record calculated as a fixed negative offset from
the mentioned data record starting address. Look at any heap manager
sources. IMHO, heap manager sources in  DJGPP RTL are too optimized
for speed and not for readability. I suggest to choose a bad (but simple)
heap manager, e.g. from Borland C++ RTL :-).

----------------------------------------------------------------------
Aleksey Kondratyev
Ph.D. student of Ulyanovsk state University, Russia
http://www.mv.ru/~akondra
E-mail akondra AT mmf DOT univ DOT simbirsk DOT su
           akondra AT mv DOT ru
If the  address above contains no-spam-, please,
remove it when replying.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019