home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / MPW / gzip 1.2.2 / cextras-1.0 / strdup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-08  |  959 b   |  32 lines  |  [TEXT/MPS ]

  1. /*
  2.     strdup.c -- duplicate a string.
  3.  
  4.     Copyright (c) 1993 Anthony C. Ard.
  5.  
  6.     This program is free software; you can redistribute it and/or
  7.     modifiy it under the terms of the GNU General Public License
  8.     as published by the Free Software Foundation; either version 2
  9.     of the License, or (at your option) any later version.
  10.     
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14.     GNU General Public License for more details.
  15.     
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #include <StdLib.h>
  22. #include <String.h>
  23.  
  24. char *strdup( const char *src )
  25. {
  26.     register char *tmp;
  27.     
  28.     tmp = (char *) malloc( (strlen( src ) + 1) * sizeof( char ) );
  29.     if( tmp ) strcpy( tmp, src );
  30.     return tmp;
  31. }
  32.