On 29 May 2018 at 10:36, Michal Privoznik <mprivozn(a)redhat.com> wrote:
On 05/28/2018 09:34 AM, Sukrit Bhatnagar wrote:
>
> This is what new macros will look like:
>
> # define _VIR_TYPE_PTR(type) type##Ptr
>
> # define _VIR_ATTR_AUTOFREE_PTR(type) __attribute__((cleanup(type##Free)))
> # define _VIR_ATTR_AUTOCLOSE_PTR(type) __attribute__((cleanup(type##Close)))
> # define _VIR_ATTR_AUTOCLEAN_PTR(type) __attribute__((cleanup(type##Clean)))
>
> # define VIR_AUTOFREE_PTR(type) _VIR_ATTR_AUTOFREE_PTR(type) _VIR_TYPE_PTR(type)
>
>
> The problem is that our vir*Free functions take on vir*Ptr as the
> parameter and not
> vir*Ptr * (pointer to it).
>
> For example, instead of:
> void virArpTableFree(virArpTablePtr table);
>
> we would need:
> void virArpTableFree(virArpTablePtr *table);
>
> if we declare something like:
> VIR_AUTOFREE_PTR(virArpTable) table = NULL;
>
>
> Also, I tried to add a new function:
> void virArpTablePtrFree(virArpTablePtr *table)
> {
> size_t i;
>
> if (!*table)
> return;
>
> for (i = 0; i < (*table)->n; i++) {
> VIR_FREE((*table)->t[i].ipaddr);
> VIR_FREE((*table)->t[i].mac);
> }
> VIR_FREE((*table)->t);
> VIR_FREE((*table));
> VIR_FREE(table);
As Erik pointed out, this last VIR_FREE(table) looks fishy. However, do
you have patch that I can apply and reproduce?
When I was using the above function, even without the last VIR_FREE(table),
I got the same error.
I am now using the original virArpTableFree function, not this.
The error is resolved for now. It seems like some other files I modified were
creating trouble. I reset them.