| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Memory matters |
Hi Bo! :-) JB>> another is not to allocate them but instead have them as ordinary JB>> global variables BS> ? From one of my programs: static scene_t scene; static element_t *elem; scene is an ordinary global variable of size (sizeof scene_t) with no need for dynamic allocation, while elem is a pointer needing dynamic allocation. The reasoning behind this is that my program handles exactly one scene, but that can contain an arbitrary number of elements. No need to allocate the scene_t with malloc() in this case. The decls are from a parser which only needs to handle one element at a time, they are then inserted into a linked list in the scene when the next element comes up - so I only need to have that one element_t pointer available in the parser code, not one for each element present. Ciao Pascal --- Msged/LNX 6.1.1* Origin: ttylinux - http://freshmeat.net/projects/ttylinux/ (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™.