diff --git a/include/tr/memory.h b/include/tr/memory.h index a438b2d..7a35428 100644 --- a/include/tr/memory.h +++ b/include/tr/memory.h @@ -34,6 +34,8 @@ void TR_free(void **); size_t TR_getSize(void *); void TR_cleanup(); +char * TR_strdup(const char *); + #endif // __TR_MEMORY_H__ // vim: set ts=4 sw=4: diff --git a/src/memory.c b/src/memory.c index 686fb50..3dd70cf 100644 --- a/src/memory.c +++ b/src/memory.c @@ -505,4 +505,19 @@ TR_cleanup() #endif } +char * +TR_strdup(const char * src) +{ + char * dup; + + if (NULL == src) { + return NULL; + } + + dup = TR_malloc(strlen(src)+1); + strcpy(dup, src); + + return dup; +} + // vim: set ts=4 sw=4: