Showing
2 changed files
with
17 additions
and
0 deletions
@@ -34,6 +34,8 @@ void TR_free(void **); | @@ -34,6 +34,8 @@ void TR_free(void **); | ||
34 | size_t TR_getSize(void *); | 34 | size_t TR_getSize(void *); |
35 | void TR_cleanup(); | 35 | void TR_cleanup(); |
36 | 36 | ||
37 | +char * TR_strdup(const char *); | ||
38 | + | ||
37 | #endif // __TR_MEMORY_H__ | 39 | #endif // __TR_MEMORY_H__ |
38 | 40 | ||
39 | // vim: set ts=4 sw=4: | 41 | // vim: set ts=4 sw=4: |
@@ -505,4 +505,19 @@ TR_cleanup() | @@ -505,4 +505,19 @@ TR_cleanup() | ||
505 | #endif | 505 | #endif |
506 | } | 506 | } |
507 | 507 | ||
508 | +char * | ||
509 | +TR_strdup(const char * src) | ||
510 | +{ | ||
511 | + char * dup; | ||
512 | + | ||
513 | + if (NULL == src) { | ||
514 | + return NULL; | ||
515 | + } | ||
516 | + | ||
517 | + dup = TR_malloc(strlen(src)+1); | ||
518 | + strcpy(dup, src); | ||
519 | + | ||
520 | + return dup; | ||
521 | +} | ||
522 | + | ||
508 | // vim: set ts=4 sw=4: | 523 | // vim: set ts=4 sw=4: |
Please
register
or
login
to post a comment