Is there a reason why you need to write such a wrapper around calloc()?
It adds very little since calloc already sets errno. Plus it's a rather
unnatural construct for an allocator to return the allocated buffer this
way.

if ((err = essid_alloc(len, &buf)) != 0)
        handle_error(err);

if (!(buf = calloc(1, len)))
        handle_error(errno);

I didn't follow the discussion, just looking at this code without context.

On 14/10/15 15:37, Edward Bartolo wrote:
> Dear All,
> 
> The problem according to my logic seems to be result is used in a
> branch control expression before it is initialised. However, I am
> emailing this to have other opinions.
> 
> 
> 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;
> }

-- 
Mat <m...@parad0x.org>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Reply via email to