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

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 7 21:53:39 PST 2014

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:

#define FSmalloc(size) malloc(((size) > 0 ? (size) : 1))
#define FSmalloc(size) malloc((size))

(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

More information about the xorg-devel mailing list