Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, TipmyPip), 12,709 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 4 1 2 3 4
Re: Saving the *contents* of a structure with game_save()... [Re: Caermundh] #365038
03/22/11 23:05
03/22/11 23:05
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Ah, now I got it. This a bit strange concept. Under normal circumstances you'd allocate memory for the string when the memory for the struct is allocated as well and you'd release it when the struct memory is released.

The more different parts in your code allocate and release memory on different occasions, the more error prone the code will be concerning memory leaks and or relese of already released memory blocks.


Always learn from history, to be sure you make the same mistakes again...
Re: Saving the *contents* of a structure with game_save()... [Re: Uhrwerk] #365045
03/23/11 00:25
03/23/11 00:25
Joined: Aug 2005
Posts: 238
Caermundh Offline OP
Member
Caermundh  Offline OP
Member

Joined: Aug 2005
Posts: 238
well, for first_struct i am doing exactly that - allocating the struct and the strings at the same time and then releasing them at the same time, at least in the second version. Not releasing the strings when i released the struct was what i disliked about the first version. First_save is different though, its supposed to be a permanently allocated area of memory (permanent for the duration of the run-time anyways.) The reason for that is because if I allocate first_save, call add_struct(first_save,sizeof(save_struct)), and then later release first_save ... well i believe that would cause an engine crash when game_save tries to save an invalid area of memory right?

Last edited by Caermundh; 03/23/11 00:29.
Page 4 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1