| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | How is memory handled? |
Hi Neil. 11-Feb-03 16:14:00, Neil Heller wrote to Darin McBride NH>> The targets of the pointers still exist ... but where? Do I need NH>> to worry about "free"ing or "delete"ing the memory? DM>> No. You didn't malloc/strdup/call any function to allocate the DM>> memory, so neither should you (or can you!) free/call any DM>> function to de-allocate the memory. NH> Is there any chance of having a memory leak when using NH> char *foo "For whom the bell tolls"; no risk. remember that char *foo = "For whom the bell tolls"; has the same effect as doing. char *foo; foo = "For whom the bell tolls"; as you see there's no heap memory allocation step, It's just pointing the pointer to memory location, in this case the location is that which the compiler creates for the literal string, foo = foo + 1; foo = NULL; etc just modify where foo points, there's no risk of a memory leak until you open that can of worms by using one of the memory allocation functions.... -=> Bye <=- ---* Origin: Money is the root of all wealth. (3:640/1042) SEEN-BY: 633/267 270 @PATH: 640/1042 531 954 774/605 123/500 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™.