Annotation of ircnowd/src/portab/strdup.c, Revision 1.1
1.1 ! tomglok 1: /*
! 2: * ngIRCd -- The Next Generation IRC Daemon
! 3: */
! 4:
! 5: #include "portab.h"
! 6:
! 7: /**
! 8: * @file
! 9: * strdup() implementation. Public domain.
! 10: */
! 11:
! 12: #ifndef HAVE_STRDUP
! 13:
! 14: #include <string.h>
! 15: #include <stdlib.h>
! 16: #include <sys/types.h>
! 17:
! 18: GLOBAL char *
! 19: strdup(const char *s)
! 20: {
! 21: char *dup;
! 22: size_t len = strlen(s);
! 23: size_t alloc = len + 1;
! 24:
! 25: if (len >= alloc)
! 26: return NULL;
! 27: dup = malloc(alloc);
! 28: if (dup)
! 29: strlcpy(dup, s, alloc );
! 30:
! 31: return dup;
! 32: }
! 33:
! 34: #endif
CVSweb