[PATCH:libXfont 2/2] Replace malloc(strlen)+strcpy/strcat calls with strdup

Alan Coopersmith alan.coopersmith at oracle.com
Wed Oct 30 05:33:32 CET 2013


On 10/29/13 07:07 PM, Jasper St. Pierre wrote:
>     +#define FontFileSaveString(s) strdup(s)
> 
> Shouldn't this #define be in a header file to be useful?

All the calls to that function in libXfont appear in that file after
the point of the #define:

% git grep FontFileSaveString
include/X11/fonts/fntfil.h:extern char * FontFileSaveString ( char *s );
src/fontfile/fontdir.c:FontFileSaveString (char *s)
src/fontfile/fontdir.c:#define FontFileSaveString(s) strdup(s)
src/fontfile/fontdir.c:	if (!(entry.u.bitmap.fileName = FontFileSaveString (fileName)))
src/fontfile/fontdir.c:		    if (!(existing->u.scalable.fileName = FontFileSaveString (fileName)))
src/fontfile/fontdir.c:	if (!(entry.u.scalable.fileName = FontFileSaveString (fileName)))
src/fontfile/fontdir.c:    if (!(entry.u.alias.resolved = FontFileSaveString (fontName)))

Still need to go through the programs that call libXfont to see if we
can safely drop this from the API or not, but this is one step forward
in the meantime.

-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list