Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | chip programmers | 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