Συντάκτης: Rainer Weikusat Ημερομηνία: Προς: dng Αντικείμενο: Re: [DNG] int essid_alloc is causing valgrind to report a series,
of errors
aitor_czr <aitor_czr@???> writes: > Hi Edward,
>
> You are pointing *result to a pointer 'tmp' declared locally inside
> the function 'essid_alloc', whose value will be lost outside it...
>
> Is it right?
No, it's not. At the point of the assignment, the value of tmp is some
value returned by calloc. And that's a pointer to some memory on the
heap which won't be deallocated automatically. In order to "point result
to the pointer 'tmp'" the line would need to read
*result = &tmp;
which wouldn't compile because *result is a char * and &tmp a char **.