• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Do locals leak

Status
Not open for further replies.
Level 19
Joined
Aug 8, 2007
Messages
2,765
title.

e/ sorry if im being vague, but i mean it in both instances (using a plain local and not nulling it and assigning a leaking function to a local and not destroying/nulling it)
 
Oh, one other thing:

JASS:
function temp takes nothing returns nothing
    local location l
    if (boolean expression) then
        set l = something
        // do stuff with l
        call RemoveLocation(l)
        set l = null
    endif
    // we don't null l here because it won't be equal to anything, and thus it won't leak
endfunction

Handles would only leak if they actually have a value
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Non-agent handles are local-only relevant objects and constants.

JASS:
local image i = CreateImage(...)

call DestroyImage(i)

call CreateImage(...)

After the last line, the variable i will contain the new, lower image because you do not need to nullify the variable here. The id will still be returned and it keeps pointing on the address.

JASS:
local image b
local image i = CreateImage(...)

call DestroyImage(i)

set b = CreateImage(...)

if (b == i) then
    call BJDebugMsg("that's the case")
endif
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Okay, i understand, but i dont understand something else.

JASS:
    call TriggerAddCondition( gg_trg_Respawn_Copy, Condition( IsNeutralHostile ) )

Is a line of the code. but when i save, it says

Cannot convert integer to boolean

JASS:
    call TriggerAddCondition(gg_trg_Respawn_Copy, Condition((1)))

Why is it compiling to 1? Yes theres a trigger above thats called isNeutralHostile

i also have a second problem

JASS:
local unit group GetUnits = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IsNeutralHostile))

(these errors might have something to do with that function)

converts to

JASS:
local unit group  = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function IsNeutralHostile))

and than yells at em because theres no name for the variable...
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
vJass gives each function a number. Write

call TriggerAddCondition( gg_trg_Respawn_Copy, Condition( function IsNeutralHostile ) )

instead or vJass also allows

call TriggerAddCondition( gg_trg_Respawn_Copy, function IsNeutralHostile )

by automatically converting it to the above.
 
Status
Not open for further replies.
Top