|
|
ptr_remove / memory question
#344628
10/19/10 07:20
10/19/10 07:20
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Hi, usually I remove my panels using:
ptr_remove(pan);
pan = NULL;
Now I'm wondering what happens with the allocated memory used for the bmaps within this panel? Do I have to remove them manually before removing the panel? Or is this done automatically during the ptr_remove(pan) call? Is there any difference using ptr_remove(pan) or pan_remove(pan)? Regards, Pegamode.
|
|
|
Re: ptr_remove / memory question
[Re: badapple]
#344632
10/19/10 08:22
10/19/10 08:22
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
Can someone confirm this? If so then the following define should do the trick, doesn't it?
#define _pan_remove(pan) if(pan->bmap != NULL) { bmap_purge(pan->bmap); ptr_remove(pan->bmap); pan->bmap = NULL; } if(pan->mouse_map != NULL) { bmap_purge(pan->mouse_map); ptr_remove(pan->mouse_map); pan->mouse_map = NULL; } if(pan->target_map != NULL) { bmap_purge(pan->target_map); ptr_remove(pan->target_map); pan->target_map = NULL; } ptr_remove(pan); pan = NULL
Regards, Pegamode.
|
|
|
Re: ptr_remove / memory question
[Re: 3dgs_snake]
#344638
10/19/10 08:50
10/19/10 08:50
|
Joined: Feb 2006
Posts: 1,011 Germany
pegamode
OP
Serious User
|
OP
Serious User
Joined: Feb 2006
Posts: 1,011
Germany
|
I know that I should set the pointer tu NULL, but I don't see any reason why to do that before removing the BMAP. Take a look at the code I posted:
if(pan->bmap != NULL) {
bmap_purge(pan->bmap);
ptr_remove(pan->bmap);
pan->bmap = NULL; }
As you can see I set the bmap pointer to NULL AFTER removing the bmap. If I call "pan->bmap = NULL;" before I couldn't call "bmap_purge(pan->bmap)" afterwards because "pan->bmap" points to NULL.
|
|
|
|