krb5_free_data

Markus Moeller huaraz at moeller.plus.com
Sat Jun 21 17:17:11 EDT 2014


Sorry I do not understand. Right now I get crashes as val->data is NULL. To 
avoid I have to do exactly the same as the function should have done. I 
expect the below.

void KRB5_CALLCONV
krb5_free_data(krb5_context context, krb5_data *val)
{
    if (val == NULL)
        return;
    If (val->data)
       free(val->data);
    free(val);
}

"Simo Sorce"  wrote in message 
news:1403371678.19579.9.camel at willson.usersys.redhat.com...

On Sat, 2014-06-21 at 17:56 +0100, Markus Moeller wrote:
> Hi,
>
>    I wonder if it wouldn't be  better to check if val->data is NULL before
> freeing ?

No, it would be useless, free(NULL); is ok, it is just a no-op.

Simo.

>   To me the function makes otherwise no sense as I have to do the
> same checks myself before  I can call the function safely.
>
>
> void KRB5_CALLCONV
> krb5_free_data(krb5_context context, krb5_data *val)
> {
>     if (val == NULL)
>         return;
>     free(val->data);
>     free(val);
> }
>
>
> Thank you
> Markus
>
>
> _______________________________________________
> krbdev mailing list             krbdev at mit.edu
> https://mailman.mit.edu/mailman/listinfo/krbdev


-- 
Simo Sorce * Red Hat, Inc * New York

_______________________________________________
krbdev mailing list             krbdev at mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev 




More information about the krbdev mailing list