:: [DNG] int essid_alloc is causing v…
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: aitor_czr
Ημερομηνία:  
Προς: dng
Αντικείμενο: [DNG] int essid_alloc is causing valgrind to report a series, of errors
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?

Aitor.

On 14/10/15 21:29, Edward Bartolo <edbarx@???> wrote:
> int essid_alloc(
>     size_t length,
>     char ** result
> ) {
>     char * tmp;

>
>     if(length==0 || !result)
>         return EINVAL;

>
>     tmp = (char *) calloc(length, 1);

>
>     if(!tmp)
>         return ENOMEM;

>
>     *result = tmp;

>     
>     return 0;
> }