[En-Nut-Discussion] DNS fix
Michel
unreal at home.nl
Thu Apr 15 22:27:16 CEST 2004
Hi Oliver,
Oops, yes, you are right about my modifications being useless.
But only in 3 places where my fixes are useless:
the last lines in ReleaseDnsHeader, ReleaseDnsQuestion() and
ReleaseDnsResource().
I checked it and all other places where I set pointers to 0 prevent
them from being freed twice.
E.g. adding dor->dor_name = 0; and dor->dor_data = 0 to ReleaseDnsResource()
DOES prevent freeing twice. (Right?)
Greetings,
Michel
> -----Original Message-----
> From: en-nut-discussion-bounces at egnite.de
> [mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of
> Oliver Schulz
> Sent: donderdag 15 april 2004 20:30
> To: 'Ethernut User Chat (English)'
> Subject: AW: [En-Nut-Discussion] DNS fix
>
>
> Hi Michel,
> > - Prevent freeing twice
> Sorry to say that, but your modifications are are useless.
> If you assign a value to a function parameter, which is
> stored normally on stack or in a register, this value is
> destroyed after the function returns, because it is just a
> copy of the passed parameter. If you want to alter the
> parameter itself, you have to pass it as a pointer, like in
> this example:
>
> static void ReleaseDnsHeader(DNSHEADER ** doh)
> {
> if (*doh) {
> NutHeapFree(*doh);
> *doh = 0;
> }
> }
>
> Regards,
> Oliver.
>
> _______________________________________________
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> http://www.egnite.de/mailman/listinfo.cgi/en-nut-> discussion
>
>
More information about the En-Nut-Discussion
mailing list