strdup.c
Upload User: zibowangxu
Upload Date: 2007-01-04
Package Size: 331k
Code Size: 2k
Category:

Ftp Client

Development Platform:

Unix_Linux

  1. /****************************************************************************  
  2.  
  3.   Copyright (c) 1999 WU-FTPD Development Group.  
  4.   All rights reserved.
  5.   
  6.   Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
  7.     The Regents of the University of California.
  8.   Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
  9.   Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
  10.   Portions Copyright (c) 1989 Massachusetts Institute of Technology.
  11.   Portions Copyright (c) 1998 Sendmail, Inc.
  12.   Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P.  Allman.
  13.   Portions Copyright (c) 1997 by Stan Barber.
  14.   Portions Copyright (c) 1997 by Kent Landfield.
  15.   Portions Copyright (c) 1991, 1992, 1993, 1994, 1995, 1996, 1997
  16.     Free Software Foundation, Inc.  
  17.  
  18.   Use and distribution of this software and its source code are governed 
  19.   by the terms and conditions of the WU-FTPD Software License ("LICENSE").
  20.  
  21.   If you did not receive a copy of the license, it may be obtained online
  22.   at http://www.wu-ftpd.org/license.html.
  23.  
  24.   $Id: strdup.c,v 1.7 1999/09/02 14:04:30 wuftpd Exp $
  25.  
  26. ****************************************************************************/
  27. #include "../src/config.h"
  28. #if defined(_AIX4)
  29. /* we don't need this for AIX4 */
  30. void ftp_strdup_dummy()
  31. {
  32. }
  33. #else
  34. #include <stddef.h>
  35. #include <stdlib.h>
  36. #ifdef BSD
  37. #include <strings.h>
  38. #else
  39. #include <string.h>
  40. #endif
  41. #include <sys/types.h>
  42. char *strdup(char *str)
  43. {
  44.     int len;
  45.     char *copy;
  46.     len = strlen(str) + 1;
  47.     if (!(copy = malloc((u_int) len)))
  48. return ((char *) NULL);
  49. #ifdef BSD
  50.     bcopy(str, copy, len);
  51. #else
  52.     memcpy(copy, str, len);
  53. #endif
  54.     return (copy);
  55. }
  56. #endif