Destroying objects [message #82763] |
Fri, 18 January 2013 08:33 |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
Hi,
as usual I'm do things wrong believing I'm not until I wake-up.
So here's the thing. I'm using a structure to describe some objects. In my case these are regions of interest. Within this structure I have real objects. So that my structure looks something like this:
MyStruct = {ROI_Structure, a:ID_Nr, b:SomeOtherParameter, c:Obj_new()}
I then fill in MyStruct.c by doing something like this:
XROI, MyImage, REGIONS_OUT = XROI_ObjRef
MyStruct.c = XROI_ObjRef
The thing is that I then replicate this structure when I add new ROIs.
So I end up with say 10 {ROI_Structure} where for each element I did something like this:
for i=0,9 do MyStruct[i].c = XROI_ObjRef[i]
If and when somewhere later in the program I want to delete object number 5... do I have to take care of using
Obj_destroy, MyStruct[5].c
Is there no alternative?
Thing is, in this structure I have many pointers and objects...
I'm I wrong in saying that I have to do the good-boy bookkeeping and free/destroy for each deleted structure element all pointers and objects?
Thanks,
Helder
|
|
|