Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=16c8d718935ac959e0cd95d0c440192717cf2e74
commit 16c8d718935ac959e0cd95d0c440192717cf2e74 Author: Michel Hermier <[email protected]> Date: Wed May 8 16:45:24 2013 +0200 libflib: Introduce f_strdup helper which handle strdup (NULL) to return NULL. diff --git a/lib/libflib/Makefile.am b/lib/libflib/Makefile.am index 354d86f..ef9546c 100644 --- a/lib/libflib/Makefile.am +++ b/lib/libflib/Makefile.am @@ -14,6 +14,7 @@ libflib_la_SOURCES = \ flist.c \ fobject.c \ fstdlib.c \ + fstring.c \ fstringlist.c \ fvalue.c diff --git a/lib/libflib/fstring.c b/lib/libflib/fstring.c new file mode 100644 index 0000000..34540b8 --- /dev/null +++ b/lib/libflib/fstring.c @@ -0,0 +1,32 @@ +/* + * stringlist.c + * + * Copyright (c) 2013 by Michel Hermier <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ + +#include "config.h" + +#include <string.h> + +#include "fstring.h" + +char *f_strdup (const char *str) { + return str != NULL ? strdup (str) : NULL; +} + +/* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libflib/fstring.h b/lib/libflib/fstring.h new file mode 100644 index 0000000..167fe49 --- /dev/null +++ b/lib/libflib/fstring.h @@ -0,0 +1,30 @@ +/* + * stringlist.h + * + * Copyright (c) 2013 by Michel Hermier <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + */ +#ifndef F_STRING_H +#define F_STRING_H + +#include "string.h" + +char *f_strdup (const char *str); + +#endif /* F_STRING_H */ + +/* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libflib/fstringlist.c b/lib/libflib/fstringlist.c index 0ace8a8..3ae12f9 100644 --- a/lib/libflib/fstringlist.c +++ b/lib/libflib/fstringlist.c @@ -1,7 +1,6 @@ /* * stringlist.c * - * Copyright (c) 2002-2006 by Judd Vinet <[email protected]> * Copyright (c) 2013 by Michel Hermier <[email protected]> * * This program is free software; you can redistribute it and/or modify @@ -26,12 +25,14 @@ #include "fstringlist.h" +#include "fstring.h" + FList *f_stringlist_append (FList *list, const char *str) { - return f_list_append (list, strdup (str)); + return f_list_append (list, f_strdup (str)); } FList *f_stringlist_deep_copy (FList *list) { - return f_list_deep_copy (list, (FCopyFunc)strdup, NULL); + return f_list_deep_copy (list, (FCopyFunc)f_strdup, NULL); } FList *f_stringlist_find (FList *list, const char *str) { diff --git a/lib/libflib/fstringlist.h b/lib/libflib/fstringlist.h index 5e36ed7..1ebfb7c 100644 --- a/lib/libflib/fstringlist.h +++ b/lib/libflib/fstringlist.h @@ -1,7 +1,7 @@ /* * stringlist.h * - * Copyright (c) 2002-2006 by Judd Vinet <[email protected]> + * Copyright (c) 2013 by Michel Hermier <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, * USA. */ -#ifndef F_STRING_H -#define F_STRING_H +#ifndef F_STRINGLIST_H +#define F_STRINGLIST_H #include "flist.h" @@ -28,6 +28,6 @@ FList *f_stringlist_deep_copy (FList *list); FList *f_stringlist_find (FList *list, const char *str); FList *f_stringlist_uniques (FList *list); -#endif /* F_STRING_H */ +#endif /* F_STRINGLIST_H */ /* vim: set ts=2 sw=2 noet: */ _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
