X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrndup.c;h=b44db2570dbfec245884784b3849b487f0ed298b;hb=5191b3546cfb6c163228c23f214e325ddf60d46f;hp=f85627e879d2f4f891060b0171f63924161068e1;hpb=a3da002108d5418471991b77ec41b0bd0d87f0c0;p=gnulib.git diff --git a/lib/strndup.c b/lib/strndup.c index f85627e87..b44db2570 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -1,7 +1,7 @@ -/* Copyright (C) 1996, 1997, 1998, 2000, 2003 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-1998, 2001-2003, 2005-2007, 2009-2013 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 @@ -14,32 +14,16 @@ 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. */ + along with this program; if not, see . */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include -#include #include -#ifndef HAVE_DECL_STRNLEN -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL_STRNLEN -size_t strnlen (); -#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); @@ -50,6 +34,3 @@ __strndup (const char *s, size_t n) new[len] = '\0'; return memcpy (new, s, len); } -#ifdef weak_alias -weak_alias (__strndup, strndup) -#endif