X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrndup.c;h=3a1b0eae2e0695b5a3aabf67fdf7187f9bd8f074;hb=2caf4791a548a8b4fb500256a6dfe05626f2e467;hp=55cb5603616b47dc43a3bb39ac1d6eb68ec40e0f;hpb=0632e115747ff96e93330c88f536d7354a7ce507;p=gnulib.git diff --git a/lib/strndup.c b/lib/strndup.c index 55cb56036..3a1b0eae2 100644 --- a/lib/strndup.c +++ b/lib/strndup.c @@ -1,8 +1,7 @@ -/* Copyright (C) 1996, 1997, 1998, 2001, 2002, 2003, 2005, 2006 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 @@ -18,36 +17,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#if !_LIBC -# include -# include "strndup.h" -#endif +#include -#include #include -#if !_LIBC -# include "strnlen.h" -# ifndef __strnlen -# define __strnlen strnlen -# endif -#endif - -#undef __strndup -#if _LIBC -# undef strndup -#endif - -#ifndef weak_alias -# define __strndup strndup -#endif +#include char * -__strndup (s, n) - const char *s; - size_t n; +strndup (char const *s, size_t n) { - size_t len = __strnlen (s, n); + size_t len = strnlen (s, n); char *new = malloc (len + 1); if (new == NULL) @@ -56,9 +35,3 @@ __strndup (s, n) new[len] = '\0'; return memcpy (new, s, len); } -#ifdef libc_hidden_def -libc_hidden_def (__strndup) -#endif -#ifdef weak_alias -weak_alias (__strndup, strndup) -#endif