1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 18:00:28 +00:00

private strdup() implementation in case libc does not provide it.

This commit is contained in:
Florian Westphal 2005-04-16 09:20:53 +00:00
parent b4363162ce
commit 8b17579e60

35
src/portab/strdup.c Normal file
View File

@ -0,0 +1,35 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
*
* strdup() implementation. Public domain.
*
* $Id: strdup.c,v 1.1 2005/04/16 09:20:53 fw Exp $
*/
#include "portab.h"
#include "imp.h"
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include "exp.h"
#ifndef HAVE_STRDUP
GLOBAL char *
strdup( const char *s )
{
char *dup;
size_t len = strlen( s );
size_t alloc = len + 1;
if (len >= alloc ) return NULL;
dup = malloc( alloc );
if (dup) strlcpy(dup, s, alloc );
return dup;
}
#endif