[postgis-devel] [wktraster] Deallocating memory (rt_band_destroy)

Mateusz Loskot mateusz at loskot.net
Thu Jan 14 10:03:59 PST 2010


Jorge Arévalo wrote:
> Hello,
> 
> rt_band_destroy function simply deallocates memory for band struct,
> because the memory for band->data is externally owned. But in
> rt_band_from_wkb, for example, memory is allocated for data, and
> should be deallocated.
> 
> Looking at the code, I think the field "ownsData" of rt_band_t struct
> informs about that, but I'm not sure. So, if I'm not wrong:
> 
> - ownsData = 0 ==> band->data is externally owned, and it mustn't be deallocated
> - ownsData = 1 ==> band->data is internally owned and it must be deallocated
> 
>  In this last case, the memory for data should be deallocated when
> destroying band in rt_band_destroy. Am I right?

Jorge,

Indeed it looks like something is missing from the rt_band_destroy.
As far as I understand, it should check if band is the owner of data
and if it is it should deallocate the data.

IOW, behaviour of ownsData member should be clarified / documented.

Sandro,

Could you give give some insights?

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net



More information about the postgis-devel mailing list