delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/24/08:57:05

Message-ID: <3590F712.DB3C02E0@compmore.net>
Date: Wed, 24 Jun 1998 08:54:43 -0400
From: stdenis <stdenis AT compmore DOT net>
MIME-Version: 1.0
To: Zixyer S Qwerty <zixyer AT juno DOT com>
CC: djgpp AT delorie DOT com
Subject: Re: free()
References: <19980623 DOT 131350 DOT 7759 DOT 0 DOT zixyer AT juno DOT com>

> 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

Well yeah, when you malloc a block, it keeps the pointer, then when you free
it it checks the pointer and returns it to the heap

Well allocate one big block (for the whole list) and use the block
dynamically.

tom

- Raw text -


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