aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sds.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/sds.c b/sds.c
index 1bc8021..eee9ed8 100644
--- a/sds.c
+++ b/sds.c
@@ -33,8 +33,8 @@
#include <string.h>
#include <ctype.h>
#include <assert.h>
+
#include "sds.h"
-#include "zmalloc.h"
/* Create a new sds string with the content specified by the 'init' pointer
* and 'initlen'.
@@ -52,9 +52,9 @@ sds sdsnewlen(const void *init, size_t initlen) {
struct sdshdr *sh;
if (init) {
- sh = zmalloc(sizeof(struct sdshdr)+initlen+1);
+ sh = malloc(sizeof(struct sdshdr)+initlen+1);
} else {
- sh = zcalloc(sizeof(struct sdshdr)+initlen+1);
+ sh = calloc(sizeof(struct sdshdr)+initlen+1,1);
}
if (sh == NULL) return NULL;
sh->len = initlen;
@@ -85,7 +85,7 @@ sds sdsdup(const sds s) {
/* Free an sds string. No operation is performed if 's' is NULL. */
void sdsfree(sds s) {
if (s == NULL) return;
- zfree(s-sizeof(struct sdshdr));
+ free(s-sizeof(struct sdshdr));
}
/* Set the sds string length to the length as obtained with strlen(), so
@@ -139,7 +139,7 @@ sds sdsMakeRoomFor(sds s, size_t addlen) {
newlen *= 2;
else
newlen += SDS_MAX_PREALLOC;
- newsh = zrealloc(sh, sizeof(struct sdshdr)+newlen+1);
+ newsh = realloc(sh, sizeof(struct sdshdr)+newlen+1);
if (newsh == NULL) return NULL;
newsh->free = newlen - len;
@@ -156,7 +156,7 @@ sds sdsRemoveFreeSpace(sds s) {
struct sdshdr *sh;
sh = (void*) (s-(sizeof(struct sdshdr)));
- sh = zrealloc(sh, sizeof(struct sdshdr)+sh->len+1);
+ sh = realloc(sh, sizeof(struct sdshdr)+sh->len+1);
sh->free = 0;
return sh->buf;
}
@@ -296,20 +296,20 @@ sds sdscatvprintf(sds s, const char *fmt, va_list ap) {
size_t buflen = 16;
while(1) {
- buf = zmalloc(buflen);
+ buf = malloc(buflen);
if (buf == NULL) return NULL;
buf[buflen-2] = '\0';
va_copy(cpy,ap);
vsnprintf(buf, buflen, fmt, cpy);
if (buf[buflen-2] != '\0') {
- zfree(buf);
+ free(buf);
buflen *= 2;
continue;
}
break;
}
t = sdscat(s, buf);
- zfree(buf);
+ free(buf);
return t;
}
@@ -474,7 +474,7 @@ sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count
if (seplen < 1 || len < 0) return NULL;
- tokens = zmalloc(sizeof(sds)*slots);
+ tokens = malloc(sizeof(sds)*slots);
if (tokens == NULL) return NULL;
if (len == 0) {
@@ -487,7 +487,7 @@ sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count
sds *newtokens;
slots *= 2;
- newtokens = zrealloc(tokens,sizeof(sds)*slots);
+ newtokens = realloc(tokens,sizeof(sds)*slots);
if (newtokens == NULL) goto cleanup;
tokens = newtokens;
}
@@ -511,7 +511,7 @@ cleanup:
{
int i;
for (i = 0; i < elements; i++) sdsfree(tokens[i]);
- zfree(tokens);
+ free(tokens);
*count = 0;
return NULL;
}
@@ -522,7 +522,7 @@ void sdsfreesplitres(sds *tokens, int count) {
if (!tokens) return;
while(count--)
sdsfree(tokens[count]);
- zfree(tokens);
+ free(tokens);
}
/* Create an sds string from a long long value. It is much faster than:
@@ -715,13 +715,13 @@ sds *sdssplitargs(const char *line, int *argc) {
if (*p) p++;
}
/* add the token to the vector */
- vector = zrealloc(vector,((*argc)+1)*sizeof(char*));
+ vector = realloc(vector,((*argc)+1)*sizeof(char*));
vector[*argc] = current;
(*argc)++;
current = NULL;
} else {
/* Even on empty input string return something not NULL. */
- if (vector == NULL) vector = zmalloc(sizeof(void*));
+ if (vector == NULL) vector = malloc(sizeof(void*));
return vector;
}
}
@@ -729,7 +729,7 @@ sds *sdssplitargs(const char *line, int *argc) {
err:
while((*argc)--)
sdsfree(vector[*argc]);
- zfree(vector);
+ free(vector);
if (current) sdsfree(current);
*argc = 0;
return NULL;