Blame gl/strdup.c

Packit Service 4684c1
/* Copyright (C) 1991, 1996-1998, 2002-2004, 2006-2007, 2009-2020 Free Software
Packit Service 4684c1
   Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This file is part of the GNU C Library.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software; you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU Lesser General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 2.1, or (at your option)
Packit Service 4684c1
   any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU Lesser General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU Lesser General Public License along
Packit Service 4684c1
   with this program; if not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef _LIBC
Packit Service 4684c1
# include <config.h>
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* Get specification.  */
Packit Service 4684c1
#include <string.h>
Packit Service 4684c1
Packit Service 4684c1
#include <stdlib.h>
Packit Service 4684c1
Packit Service 4684c1
#undef __strdup
Packit Service 4684c1
#ifdef _LIBC
Packit Service 4684c1
# undef strdup
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
#ifndef weak_alias
Packit Service 4684c1
# define __strdup strdup
Packit Service 4684c1
#endif
Packit Service 4684c1
Packit Service 4684c1
/* Duplicate S, returning an identical malloc'd string.  */
Packit Service 4684c1
char *
Packit Service 4684c1
__strdup (const char *s)
Packit Service 4684c1
{
Packit Service 4684c1
  size_t len = strlen (s) + 1;
Packit Service 4684c1
  void *new = malloc (len);
Packit Service 4684c1
Packit Service 4684c1
  if (new == NULL)
Packit Service 4684c1
    return NULL;
Packit Service 4684c1
Packit Service 4684c1
  return (char *) memcpy (new, s, len);
Packit Service 4684c1
}
Packit Service 4684c1
#ifdef libc_hidden_def
Packit Service 4684c1
libc_hidden_def (__strdup)
Packit Service 4684c1
#endif
Packit Service 4684c1
#ifdef weak_alias
Packit Service 4684c1
weak_alias (__strdup, strdup)
Packit Service 4684c1
#endif