From dad8d67ed017dfa8a9e674056c93ae7ab73d51cf Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Wed, 30 Dec 1998 20:17:02 +0000 Subject: [PATCH] add isc_mem_strdup --- lib/isc/include/isc/mem.h | 1 + lib/isc/mem.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index 5f3aed1b68..16871a621e 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -46,6 +46,7 @@ void isc_mem_stats(isc_mem_t *, FILE *); isc_boolean_t isc_mem_valid(isc_mem_t *, void *); void * isc_mem_allocate(isc_mem_t *, size_t); void isc_mem_free(isc_mem_t *, void *); +char * isc_mem_strdup(isc_mem_t *, const char *); #ifdef ISC_MEMCLUSTER_LEGACY diff --git a/lib/isc/mem.c b/lib/isc/mem.c index 78406cb438..51785de8ff 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -438,6 +438,20 @@ isc_mem_free(isc_mem_t *ctx, void *ptr) { isc_mem_put(ctx, si, si->size); } +char * +isc_mem_strdup(isc_mem_t *mctx, const char *s) { + size_t len; + char *ns; + + len = strlen(s); + ns = isc_mem_allocate(mctx, len + 1); + if (ns == NULL) + return (NULL); + strncpy(ns, s, len + 1); + + return (ns); +} + #ifdef ISC_MEMCLUSTER_LEGACY /*