malloc in pawn?
Hello, i need to know what is malloc in pawn,
I need to found this function but i did not found it in any include file. However i search from google and it seems like there are not that function in pawn like malloc. Can someone help me? :) |
Re: malloc in pawn?
Doesn't exist in AMXX Pawn.
|
Re: malloc in pawn?
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. |
Re: malloc in pawn?
I would like to clearify something.
In terms of memory usage it means creating Array[33 char] would be more efficient than Array[33] ? However, creating a simple variable (new SomeVar) would be even more effecient than Array[33 char] if bit shifting is used to assign values to SomeVar (but for simple variables there is a strict limitation as to how many values can be assigned) ? ConnorMcLeod mentioned that this char functionality is not supported by any amxx native yet I have seen plugins using arrays with chars without having any appearant problems. For example if I'm using iMoney[33 char] array to store every player's money, would it cause any problems (I'm simply talking about setting and retrieving values from array, not formatting or anything like that) ? And lastly, would this work ? new Array[95 char] Array{83} = 235315 |
Re: malloc in pawn?
Create [33 char] uses 33 bytes or memory, create [33] uses 132, though it's not a big deal nowadays, and also, i'm not sur but i think that a fix amount of memory is reserved to each plugin.
You can only set a value between 0 and 255, so you won't buy a lot of thing to such few money :P When i said no native supports it, i meant this for strings. |
Re: malloc in pawn?
Ok, thanks.
|
| All times are GMT -4. The time now is 00:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.