• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Doesn't this leak unit handles or something?

Status
Not open for further replies.
[jass=]
function CreateNeutralPassiveBuildings takes nothing returns nothing
local player p = Player(PLAYER_NEUTRAL_PASSIVE)
local unit u
local integer unitID
local trigger t
local real life

set u = CreateUnit( p, 'hgtw', 1984.0, 4160.0, 270.000 )
set u = CreateUnit( p, 'h00E', -309.6, 2466.0, 166.854 )
set u = CreateUnit( p, 'h00E', -795.8, 1918.7, 44.881 )
set u = CreateUnit( p, 'h00E', -2567.6, -265.1, 80.223 )
set u = CreateUnit( p, 'h00E', -1453.7, -332.0, 112.120 )
set u = CreateUnit( p, 'h00E', -1848.3, -1199.8, 92.250 )
set u = CreateUnit( p, 'h00E', -2069.6, -625.1, 70.911 )
set u = CreateUnit( p, 'h00E', -2519.9, -1225.0, 60.597 )
set u = CreateUnit( p, 'h00L', 278.8, -2702.0, 150.924 )
set u = CreateUnit( p, 'h00E', 262.7, -3160.4, 131.324 )
set u = CreateUnit( p, 'h00E', 438.3, -2410.5, 170.462 )
set u = CreateUnit( p, 'h00E', 607.3, -2947.5, 148.583 )
set u = CreateUnit( p, 'h00E', 1704.2, -2313.2, 211.002 )
set u = CreateUnit( p, 'h00E', 1762.5, -2684.5, 184.750 )
set u = CreateUnit( p, 'h00E', 1787.4, -3013.1, 161.986 )
set u = CreateUnit( p, 'h00E', 1794.3, -3499.0, 137.466 )
set u = CreateUnit( p, 'h00E', 1483.1, -3490.9, 124.298 )
set u = CreateUnit( p, 'h00E', 1521.1, -3227.4, 138.691 )
set u = CreateUnit( p, 'h00E', 1501.9, -2935.9, 160.452 )
set u = CreateUnit( p, 'h00E', 1468.2, -2560.3, 201.113 )
set u = CreateUnit( p, 'h00E', 1449.0, -2234.5, 227.547 )
set u = CreateUnit( p, 'h00E', 2031.6, -2262.9, 204.794 )
set u = CreateUnit( p, 'h00E', 2048.1, -2507.2, 192.765 )
set u = CreateUnit( p, 'h00E', 2048.6, -2813.7, 176.583 )
set u = CreateUnit( p, 'h00E', 2032.0, -3019.2, 165.663 )
set u = CreateUnit( p, 'h00E', 2016.6, -3271.4, 153.341 )
set u = CreateUnit( p, 'h00E', 2015.9, -3459.8, 145.633 )
set u = CreateUnit( p, 'h00L', 2422.8, -2457.2, 191.444 )
set u = CreateUnit( p, 'h00L', 2377.9, -3418.3, 154.478 )
set u = CreateUnit( p, 'h00L', 2410.8, -2963.5, 171.517 )
set u = CreateUnit( p, 'h00M', 2821.8, -3033.8, 171.244 )
endfunction
[/code]

As in doesn't it leak locals?
 
If you initialisize an agent type like unit (you do so), you have to null the variable once you're finished with it.
So you can simply write this line in the end of your function:
JASS:
function CreateNeutralPassiveBuildings takes nothing returns nothing
    ... // do your code
    set u = null  // for no reference leak
endfunction
A reference leak is a minor one, but still a leak. :)
 
Status
Not open for further replies.
Top