home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xgrasp.zip / STRDUP.C < prev    next >
C/C++ Source or Header  |  1992-09-04  |  1KB  |  40 lines

  1. #ident "@(#)strdup.c    1.1 91/03/02 XGRASP"
  2. /*-
  3.  * strdup.c - duplicate a string.
  4.  *
  5.  * Copyright (c) 1991 by Patrick J. Naughton
  6.  *
  7.  * Permission to use, copy, modify, and distribute this software and its
  8.  * documentation for any purpose and without fee is hereby granted,
  9.  * provided that the above copyright notice appear in all copies and that
  10.  * both that copyright notice and this permission notice appear in
  11.  * supporting documentation.
  12.  *
  13.  * This file is provided AS IS with no warranties of any kind.  The author
  14.  * shall have no liability with respect to the infringement of copyrights,
  15.  * trade secrets or any patents by this file or any part thereof.  In no
  16.  * event will the author be liable for any lost revenue or profits or
  17.  * other special, indirect and consequential damages.
  18.  *
  19.  * Comments and additions should be sent to the author:
  20.  *
  21.  * Patrick J. Naughton
  22.  * Sun Microsystems
  23.  * 2550 Garcia Ave, MS 10-20
  24.  * Mountain View, CA 94043
  25.  * (415) 336-1080
  26.  *
  27.  */
  28.  
  29. extern char *malloc();
  30. extern unsigned long strlen();
  31. extern char *strcpy();
  32.  
  33. char       *
  34. strdup(s)
  35.     char       *s;
  36. {
  37.     char       *new = malloc(strlen(s) + 1);
  38.     return (new ? strcpy(new, s) : (char *) 0);
  39. }
  40.