HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Will this code leak because of the locations?

02-27-2004, 11:48 PM#1
Squashy
I'd like to clarify something for myself. The following function is of no real use, but merely a simple example to demonstrate my question.
Code:
function silly takes nothing returns nothing
    local location loc = Location(0,0)

    set loc = Location(1,1)

    set loc = Location(3,3)
  
    set loc = Location(7,7)

    call RemoveLocation(loc)
endfunction

I remove the location at the end of the function. However, I set loc to four different locations.

My assumption:
Handles act like pointers, so it will only delete what it is pointing to. (The location corresponding to 7,7) Therefore, the earlier locations are still stuck out in memory.

Am I correct in this thinking?
02-28-2004, 12:54 AM#2
Vidstige
It seems reasonable, if it had been a traditional language it would have been that way at least.
02-28-2004, 02:07 AM#3
weaaddar
yeah you are leaking three locations with that code.
02-28-2004, 01:00 PM#4
jmoritz
And 1 handle as well. But handles use so little memory, don't worry about that :)