Mercurial > hg > nnchat
comparison th_string.c @ 79:e36df57c5b0f
Use th_strdup() again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 24 Dec 2008 16:03:53 +0200 |
parents | e47955d42b55 |
children | 69aed051f84d |
comparison
equal
deleted
inserted
replaced
78:745f670068dc | 79:e36df57c5b0f |
---|---|
10 #endif | 10 #endif |
11 #include "th_string.h" | 11 #include "th_string.h" |
12 | 12 |
13 #define LPREV (pNode->pPrev) | 13 #define LPREV (pNode->pPrev) |
14 #define LNEXT (pNode->pNext) | 14 #define LNEXT (pNode->pNext) |
15 | |
16 | |
17 /* strdup with a NULL check | |
18 */ | |
19 char *th_strdup(const char *s) | |
20 { | |
21 char *res; | |
22 if (s == NULL) | |
23 return NULL; | |
24 | |
25 if ((res = th_malloc(strlen(s) + 1)) == NULL) | |
26 return NULL; | |
27 | |
28 strcpy(res, s); | |
29 return res; | |
30 } | |
31 | |
15 | 32 |
16 /* Allocate memory for a string with given length | 33 /* Allocate memory for a string with given length |
17 */ | 34 */ |
18 char *th_stralloc(const size_t l) | 35 char *th_stralloc(const size_t l) |
19 { | 36 { |