Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (Ayumi), 662 guests, and 3 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
String memory allocation #365527
03/27/11 12:23
03/27/11 12:23
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Hi jcl,

I have a question to the Lite-C compiler. Is this code allowed:

Code:
while(1)
{
STRING* TestStr = "#100";
//...
wait(1);
}



Or do I have to use str_create() instead of "#100"?

Thanks for your help!


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version
Re: String memory allocation [Re: Dark_samurai] #365654
03/28/11 10:57
03/28/11 10:57
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, you need str_create() inside a function. Also, take care that the string is not created again whenever you call the function - otherwise the memory is slowly consumed up.

On that occasion, I suggest that when you have the choice, prefer create() functions over global definitions. When you want to port your project later to phone APIs such as Android with a future Gamestudio version, you will have to use create functions for engine objects.

Re: String memory allocation [Re: jcl] #365656
03/28/11 11:09
03/28/11 11:09
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
"When you want to port your project later to phone APIs such as Android with a future Gamestudio version[...]"

When is that possible??!!! Do you have an ETA?


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: String memory allocation [Re: alibaba] #365657
03/28/11 11:19
03/28/11 11:19
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No, there's still a lot to do, we're far from an ETA.

Re: String memory allocation [Re: jcl] #365661
03/28/11 12:05
03/28/11 12:05
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline OP
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Ah ok, good to know! Thanks for your help!

Quote:
When you want to port your project later to phone APIs such as Android with a future Gamestudio version, you will have to use create functions for engine objects.


Sounds promising laugh


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version

Moderated by  old_bill, Tobias 

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