strdup.c 646 B

123456789101112131415161718192021222324252627282930313233
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #if defined( ultrix ) || defined( nextstep )
  13. #include <string.h>
  14. char *strdup( char *s )
  15. {
  16. char *p;
  17. if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
  18. return( NULL );
  19. strcpy( p, s );
  20. return( p );
  21. }
  22. #else
  23. typedef int SHUT_UP_DAMN_COMPILER;
  24. #endif /* ultrix || nextstep */