Annotation of embedaddon/ntp/libntp/strdup.c, revision 1.1

1.1     ! misho       1: #include <config.h>
        !             2: 
        !             3: #include <string.h>
        !             4: #include "ntp_malloc.h"
        !             5: 
        !             6: #ifndef HAVE_STRDUP
        !             7: 
        !             8: char *strdup(const char *s);
        !             9: 
        !            10: char *
        !            11: strdup(
        !            12:        const char *s
        !            13:        )
        !            14: {
        !            15:        size_t  octets;
        !            16:        char *  cp;
        !            17: 
        !            18:        if (s) {
        !            19:                octets = 1 + strlen(s);
        !            20:                cp = malloc(octets);
        !            21:                if (NULL != cp)
        !            22:                        memcpy(cp, s, octets);
        !            23:        else
        !            24:                cp = NULL;
        !            25: 
        !            26:        return(cp);
        !            27: }
        !            28: #else
        !            29: int strdup_c_nonempty_compilation_unit;
        !            30: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>