| 02-05-2007, 12:24 AM | #1 |
Is it possible? I suppose it'd be easy enough to use a global array... Also, how would I prevent memory leaks? Thanks! Capt. Picard |
| 02-05-2007, 12:27 AM | #2 |
JASS:function whatever takes nothing returns nothing local unit array YourUnitArray endfunction Prevent which memory leaks exactly? If you mean regarding the array, then you wouldn't have to worry, the array itself effectively only points to existing units, so you don't need to worry about it leaking anything. Here's a couple of tutorials on the subject in general. http://www.wc3campaigns.net/showthread.php?t=55022 http://www.wc3campaigns.net/showthread.php?t=80072 |
| 02-05-2007, 12:35 AM | #3 |
Very nice! Thanks! I think I'll still have to set JASS:set YourUnitArray = null at the end of the function to prevent the small handle memory leak, no? |
| 02-05-2007, 12:39 AM | #4 |
Honestly, not sure. I don't think so though. You could do so just in case, but I' pretty sure that even if it leaked it wouldn't be much of one. |
| 02-05-2007, 12:44 AM | #5 |
I'm pretty sure you can't null an entire array at once. I don't know if you need to null it, but if you want to you'd probably have to null it 1 part at a time. |
| 02-05-2007, 12:56 AM | #6 |
When a function scope ends, the array reference counts are automatically decreased. aka you don't need to null array indexes Edit: pipedream claims the opposite, so you better null stuff. Most of the times, you don't really need a local array and a global one works better... |
