aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/strings.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-19 01:17:54 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2015-04-19 01:17:54 -0300
commit86b551fdf2a8bf5c6e3cebcc463ee830d65ced94 (patch)
tree2ea95245b5d1e82d8a7197206e2b640aa54119aa /src/utils/strings.c
parentfbc22f39090802845c3a046c3e10bae63d6af6cc (diff)
downloadblogc-86b551fdf2a8bf5c6e3cebcc463ee830d65ced94.tar.gz
blogc-86b551fdf2a8bf5c6e3cebcc463ee830d65ced94.tar.bz2
blogc-86b551fdf2a8bf5c6e3cebcc463ee830d65ced94.zip
safe mallocs are better :)
Diffstat (limited to 'src/utils/strings.c')
-rw-r--r--src/utils/strings.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/strings.c b/src/utils/strings.c
index b3a19cc..04ccc7a 100644
--- a/src/utils/strings.c
+++ b/src/utils/strings.c
@@ -125,14 +125,14 @@ b_str_split(const char *str, char c, unsigned int max_pieces)
{
if (!str)
return NULL;
- char **rv = malloc(sizeof(char*));
+ char **rv = b_malloc(sizeof(char*));
unsigned int i, start = 0, count = 0;
for (i = 0; i < strlen(str) + 1; i++) {
if (str[0] == '\0')
break;
if ((str[i] == c && (!max_pieces || count + 1 < max_pieces)) || str[i] == '\0') {
rv = realloc(rv, (count + 1) * sizeof(char*));
- rv[count] = malloc(i - start + 1);
+ rv[count] = b_malloc(i - start + 1);
memcpy(rv[count], str + start, i - start);
rv[count++][i - start] = '\0';
start = i + 1;
@@ -198,7 +198,7 @@ b_strv_length(char **strv)
b_string_t*
b_string_new(void)
{
- b_string_t* rv = malloc(sizeof(b_string_t));
+ b_string_t* rv = b_malloc(sizeof(b_string_t));
rv->str = NULL;
rv->len = 0;
rv->allocated_len = 0;