| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | How is memory handled? |
Hello Neil! Replying to a message of Neil Heller 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 variable, JB>> the targets of the pointers still exist because they are string the JB>> constants. NH> The targets of the pointers still exist ... but where? Do I need to NH> worry about "free"ing or "discard"ing the memory? No. You didn't malloc/strdup/call any function to allocate the memory, so neither should you (or can you!) free/call any function to de-allocate the memory. The reverse, however, does not always hold. Just because you called a function to get a pointer to memory does not mean you need to call a function to release that pointer - the original function may have returned a pointer to a static variable. Darin ---* Origin: Tanktalus' Tower BBS (1:250/102) SEEN-BY: 633/267 270 @PATH: 250/102 99 10/345 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™.