TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Roger Scudder
from: Pascal Schmidt
date: 2003-10-17 16:54:50
subject: Memory matters

Hi Roger! :-)

 RS> Freeing a structure should be nothing more than one line...
 RS> free(PointerToMyStructure);
Unless the structure contains malloc'd pointers itself, in which case
those have to be freed first. Additional fun if the structures pointed to
by embedded pointers can contain further pointers... :)

I usually code functions called destroy_foo() for each structure foo that
has embedded pointers. That hides the complexety and code needing to
destroy a variable temp of type foo does indeed only have to do

    destroy_foo(temp);

Ciao
Pascal

--- Msged/LNX 6.1.1
* Origin: The universe is laughing behind your back. (1:153/401.2)
SEEN-BY: 633/267 270
@PATH: 153/401 307 140/1 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.