HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Interesting thought on premature returning

05-28-2004, 02:50 AM#1
Narwanza
Take this example
Code:
function me takes nothing returns nothing
    local integer i = 0
    local location l = Location(344,766)
    local location j = Location(654,1098)
    if (i == 0) then
        return
    endif
    call RemoveLocation(l)
    call RemoveLocation(j)
endfunction

Would the two locations leak?
05-28-2004, 03:35 AM#2
The Gearhead
Shouldn't it be:

Locations
Return (valid answer)
Remove location
Return null

Or is that unnecessary?
05-28-2004, 07:47 AM#3
PitzerMike
As the function doesn't return anything, 'return' is the only valid return.
05-28-2004, 11:31 AM#4
AIAndy
Yes, sure that will leak since the removing of the locations is never executed.
05-28-2004, 04:53 PM#5
Narwanza
argh....... k, thx andy