|
|
I've a couple of questions about creation, deletion
and memory management of these classes. I browsed
through the source codes, but I'm still confused.
Let's say I create an Fl_RGB_Image from a simple array:
uchar *img; //assume w, h, and d have right values
Fl_RGB_Image *rgbimg = new Fl_RGB_Image(img, w, h, d);
At this point how many copies of the original image
are there in the memory? As I see in Fl_Image.cxx
there is still one copy (pointed by img), but pointers
internal to Fl_RGB_Image class are now pointing to that
copy as well. Is this correct?
Second, if I want to free the memory associated with this
image what would be the right thing to do? For instance,
again as I see from the code, calling "delete rgbimage"
will not free the memory in this case due to the following
statement in Fl_Image.cxx:
if (alloc_array) delete[] (uchar *)array;
and since alloc_array was set to zero in the constructor
called above.
Then it seems that I should also call: delete[] img;
Isn't it?
I've another question of secondary importance.
Why are there two pointers, namely data_ (in Fl_Image)
and array (in Fl_RGB_Image), don't they point to the
same thing always? And by the way what exactly does the
following declaration mean?
const char * const *data_; //from Fl_Image.H
Is it a constant pointer to a constant memory location?
Thanks for any help,
Oguz
[ Direct Link to Message ] | |
|
| |