PDA

View Full Version : How to deal with ADT arrays? best practices?


fakuivan
11-07-2015, 02:52
Hi there!

I noticed that there is not much documentation about theese objects, I need to work with them in a plugin that I am working on, could you link me to some wiki or explain those for me, I heared that they can cause a lot of problems if you don't close or clear them, I need them mainly to send an array of values obtained from a database to other plugins. I just started programming in sourcepawn (I programed in java, mainly android apps and I have some experience in c++), so pls keep that in mind.

:crab:

fakuivan
11-07-2015, 21:25
no answers yet...?

Potato Uno
11-07-2015, 21:27
Be more specific in what you want to do.

adt_arrays are dynamically sized arrays. They use handles as they are C++ objects on the C++ side. As such, you need to close them when you are done using them or you will have a memory leak (since sourcepawn has no garbage collection).

Here are all the ways to use them:

https://sm.alliedmods.net/new-api/adt_array

ThatOneGuy
11-07-2015, 22:45
Here is an explanation I made for Headline a while back: http://pastebin.com/R3LSFGi7

That is for global handles that dont end up needing to be closed (the handle will be closed when the plugin is unloaded). If you create a local ADT array, be sure to use CloseHandle on it when you are done with it inside of your function. As noted in the file, make sure you initialize it before you use it.

fakuivan
11-08-2015, 02:00
Be more specific in what you want to do.

adt_arrays are dynamically sized arrays. They use handles as they are C++ objects on the C++ side. As such, you need to close them when you are done using them or you will have a memory leak (since sourcepawn has no garbage collection).

Here are all the ways to use them:

https://sm.alliedmods.net/new-api/adt_array

So, they are not native pawn objects. thanks for that

Here is an explanation I made for Headline a while back: http://pastebin.com/R3LSFGi7

That is for global handles that dont end up needing to be closed (the handle will be closed when the plugin is unloaded). If you create a local ADT array, be sure to use CloseHandle on it when you are done with it inside of your function. As noted in the file, make sure you initialize it before you use it.

Great!