Raised This Month: $ Target: $400
 0% 

malloc in pawn?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-19-2012 , 10:47   Re: malloc in pawn?
Reply With Quote #1

Doesn't exist in AMXX Pawn.
__________________

Last edited by <VeCo>; 05-19-2012 at 11:00.
<VeCo> is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-19-2012 , 11:06   Re: malloc in pawn?
Reply With Quote #2

The only data size in pawn is cell (4 bytes), you can only declare variables that have that size or array of such type :

new var
new Float:var
new bool:var

All of them uses a cell.

You can declare arrays :

new string[32]
new bool:IsPlayerCheater[33]


Note that pawn let you declare char arrays doing : new array[128 char] but it is not supported by any amxx native.
You could use it anyway instead of player bool variable :

new bool:g_HasParachute[33]
-> g_HasParachute[player] = true , g_HasParachute[player] = false

Instead you can do :
new g_HasParachute[33 char]
g_HasParachute{id} = 1

It will use less memory.



If you don't want to allocate memory each time, consider using static variables inside functions, or global variables.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-19-2012 at 11:09.
ConnorMcLeod is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode