TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Pascal Schmidt
from: Darin McBride
date: 2003-10-17 14:55:04
subject: Memory matters

Hello Pascal!

Replying to a message of Pascal Schmidt to Roger Scudder:

 PS> Hi Roger! :-)

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

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

 PS>     destroy_foo(temp);

Welcome to C++.  ;-)

Darin

---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 633/267 270
@PATH: 250/102 99 10/345 106/1 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™.