Suggestion: include functions to free a result

Iñaki Baz Castillo ibc at aliax.net
Mon Feb 7 09:49:19 MSK 2011


2011/2/7 Iñaki Baz Castillo <ibc at aliax.net>:
> 2011/2/7 Iñaki Baz Castillo <ibc at aliax.net>:
>> Wouldn't be great if udns provides functions to free  result? i.e:
>> dns_free_rr_a4(struct dns_rr_a4 *). Just wondering.
>
> However I'm very confused now. In my callback routine I try to free
> the result and get a fatal error:
>
>  static void dns_res_A_cb(struct dns_ctx *dns_context, struct
> dns_rr_a4 *rr, void *data)
>  {
>      [...]
>      free(rr->dnsa4_qname);
>  }
>
> It produces:
>
>  *** glibc detected *** munmap_chunk(): invalid pointer: 0x0000000001b4e7d8 ***
>  ======= Backtrace: =========
>  /lib/libc.so.6(+0x774b6)[0x7fa9330314b6]
>
>
> So I'm a bit lost here, why cannot I free the result? In fact my
> application leaks, and IMHO it occurs because, for now, I don't free
> the result.


Ok, by calling "free(rr)" the leak dissapears totally. So I must
inspect how struct dns_rr_a4 is filled, aren't their fields
dynamically allocated? (I could be missing something basic in C
language right now, sorry).

Regards.


-- 
Iñaki Baz Castillo
<ibc at aliax.net>


More information about the udns mailing list