X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrndup.c;h=3a1b0eae2e0695b5a3aabf67fdf7187f9bd8f074;hb=7b01a885219f9d3870cedcc5c049a80756271538;hp=6f59717cfab46b0c6dd3d6f326cc87fc75e57888;hpb=0171fae6af885d8e76fb03a7f64f6f68fc6c5dd1;p=gnulib.git diff --git a/lib/strndup.c b/lib/strndup.c index 6f59717cf..3a1b0eae2 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -1,7 +1,7 @@ -/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc. +/* A replacement function, for systems that lack strndup. - NOTE: The canonical source of this file is maintained with the GNU C Library. - Bugs can be reported to bug-glibc@prep.ai.mit.edu. + Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006, 2007 + Free Software Foundation, Inc. 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 @@ -15,31 +15,16 @@ 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. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include -#include -#include +#include -#if defined _LIBC || defined STDC_HEADERS -# include -# include -#else -char *malloc (); -#endif - -#undef __strndup -#undef strndup - -#ifndef weak_alias -# define __strndup strndup -#endif +#include char * -__strndup (const char *s, size_t n) +strndup (char const *s, size_t n) { size_t len = strnlen (s, n); char *new = malloc (len + 1); @@ -48,8 +33,5 @@ __strndup (const char *s, size_t n) return NULL; new[len] = '\0'; - return (char *) memcpy (new, s, len); + return memcpy (new, s, len); } -#ifdef weak_alias -weak_alias (__strndup, strndup) -#endif