[PATCH:libFS 6/7] Replace malloc(strlen + 1); strcpy() with strdup()

Jasper St. Pierre jstpierre at mecheye.net
Tue Jan 7 22:20:52 PST 2014


OK then.

Reviewed-by: Jasper St. Pierre <jstpierre at mecheye.net>


On Wed, Jan 8, 2014 at 12:53 AM, Alan Coopersmith <
alan.coopersmith at oracle.com> wrote:

> On 01/ 7/14 09:38 PM, Jasper St. Pierre wrote:
>
>> Does FSmalloc do anything special, or is it just a wrapper for historical
>> reasons?
>>
>
> It's mostly historical.  src/FSlibos.h defines it as:
>
> #ifdef MALLOC_0_RETURNS_NULL
> #define FSmalloc(size) malloc(((size) > 0 ? (size) : 1))
> #else
> #define FSmalloc(size) malloc((size))
> #endif
>
> (plus similar for FScalloc & FSrealloc).
>
> The +1 for the string-ending \0 byte ensures that the size will always be
> >0,
> thus the difference doesn't matter.
>
> --
>         -Alan Coopersmith-              alan.coopersmith at oracle.com
>          Oracle Solaris Engineering - http://blogs.oracle.com/alanc
>



-- 
  Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140108/06b993a3/attachment.html>


More information about the xorg-devel mailing list