#include <assert.h>
#include "str.h"
+#include "system/nth_alloc.h"
char *string_duplicate(const char *str,
const char *str_end)
}
const size_t n = str_end == NULL ? strlen(str) : (size_t) (str_end - str);
- char *dup_str = malloc(sizeof(char) * (n + 1));
+ char *dup_str = nth_alloc(sizeof(char) * (n + 1));
if (dup_str == NULL) {
return NULL;
}
return string_duplicate(suffix, NULL);
}
- prefix = realloc(prefix, strlen(prefix) + strlen(suffix) + 1);
+ prefix = nth_realloc(prefix, strlen(prefix) + strlen(suffix) + 1);
return strcat(prefix, suffix);
}