SRL Archive - Help

Using Wrappers


DannyRS

2012-12-31 22:04:52

Problem Solved, thanks to riwu and wardancer for their help

Hey guys, been doing pretty much everything in my scripts lately with TPA's these days, and i read somewhere the other day that some sorting and splitting Includes Can cause small memory leaks or such without wrappers,

There seems to be as someone mentioned an include for a wrapper version of this:


ATPA := SplitTPAEx(TPA, 10, 10);


ATPA := SplitTPAExWrap(TPA, 10, 10, res);

Problem is the wrapper version has a parameter called res which i dont know what to pass into? Can someone that has used this explain what its used for in the included function? :p

Also if you can recall any other simular functions that should use a wrap for good memory management practise feel free to let me know ;)

Wardancer

2012-12-31 22:20:02

res is the ATPA.

DannyRS

2012-12-31 22:23:04

From: Wardancer
res is the ATPA.


Oh so you would just call it like this?


ATPA := SplitTPAExWrap(TPA, 10, 10, ATPA);

Seems weird to pass something your declairing into the function?

riwu

2012-12-31 22:25:58

res = result ;)
You simply call

SplitTPAExWrap(TPA, 10, 10, ATPA);
It's like a procedure rather than a function.

The leaking problem arise from arrays returning from simba functions are not being cleared properly after use in PS, hence the wrappers store the result array in a var parameter instead of returning it as function result.

All functions that have wrappers should only be used with the wrapper versions in PS. So just search 'wrap' in function list and you will find them all.
Note that there are a few functions where a wrapper should be used but has yet to be added. (eg. FloodFillTPA) In those cases, you would have to manage the leak yourself by setting the result length to 0 afterwards.

DannyRS

2012-12-31 22:32:42

From: riwu
res = result ;)
You simply call

SplitTPAExWrap(TPA, 10, 10, ATPA);
It's like a procedure rather than a function.

The leaking problem arise from arrays returning from simba functions are not being cleared properly after use in PS, hence the wrappers store the result array in a var parameter instead of returning it as function result.

All functions that have wrappers should only be used with the wrapper versions in PS. So just search 'wrap' in function list and you will find them all.
Note that there are a few functions where a wrapper should be used but has yet to be added. (eg. FloodFillTPA) In those cases, you would have to manage the leak yourself by setting the result length to 0 afterwards.


Ahh Thanks for explaining riwu, now i get it!