TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Neil Heller
from: Jasen Betts
date: 2003-02-12 06:22:44
subject: How is memory handled?

Hi Neil.

10-Feb-03 08:43:00, Neil Heller wrote to Jasen Betts


 NH>> The question with which I am interested is what happens to the
 NH>> memory used by the array after foo* goes out of scope?

 JB>> the array of pointers is discarded like any mundane local
 JB>> variable, the targets of the pointers still exist because they
 JB>> are string the constants.

 NH> The targets of the pointers still exist ... but where?  Do I need
 NH> to worry about "free"ing or "discard"ing the memory?

no, the pointers point to the part of the compiled program,
that contains the string constants. trying to free them wouldn't work.

if you look at a progream with a hex reader (or similar) you'll see the
printf strings etc, the woirds used in your char* initialisation haave a
similar type and will appear next to other literal strings.

If you can ask your compiler for assembler output. that should make things
clear.


 NH> þ CMPQwk 1.42 999



 -=> Bye <=-

---
* Origin: Entropy isn't what it used to be. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 106/1 379/1 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™.