Mercurial > hg > th-libs
comparison th_string.c @ 222:723a69185102
Fix th_str{n}dup_trim() functions.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Feb 2016 10:45:05 +0200 |
parents | 81b4688f684b |
children | d58b92ef5c03 |
comparison
equal
deleted
inserted
replaced
221:81b4688f684b | 222:723a69185102 |
---|---|
72 for (end = len; end > start && th_isspace(src[end]); end--); | 72 for (end = len; end > start && th_isspace(src[end]); end--); |
73 else | 73 else |
74 end = len; | 74 end = len; |
75 | 75 |
76 // Allocate memory for result | 76 // Allocate memory for result |
77 len = end - start + 1; | 77 len = end - start; |
78 if (len == 0) | |
79 return NULL; | |
80 | |
78 if ((res = th_malloc(len + 1)) == NULL) | 81 if ((res = th_malloc(len + 1)) == NULL) |
79 return NULL; | 82 return NULL; |
80 | 83 |
81 memcpy(res, src, len); | 84 memcpy(res, src, len); |
82 res[len] = 0; | 85 res[len] = 0; |