1.1 --- a/templates/native.c Sun Nov 27 22:47:09 2016 +0100
1.2 +++ b/templates/native.c Sun Nov 27 22:48:35 2016 +0100
1.3 @@ -1,4 +1,4 @@
1.4 -#include <stdlib.h> /* calloc, exit, realloc */
1.5 +#include <stdlib.h> /* exit */
1.6 #include <unistd.h> /* read, write */
1.7 #include <math.h> /* ceil, log10, pow */
1.8 #include <string.h> /* strcmp, strncpy, strlen */
1.9 @@ -252,7 +252,7 @@
1.10 /* self.__data__ interpreted as int */
1.11 int i = __load_via_object(self->value, __pos___data__).intvalue;
1.12 int n = i != 0 ? (int) ceil(log10(i+1)) + 1 : 2;
1.13 - char *s = calloc(n, sizeof(char));
1.14 + char *s = (char *) __ALLOCATE(n, sizeof(char));
1.15
1.16 if (i < 0) n++;
1.17 snprintf(s, n, "%d", i);
1.18 @@ -269,7 +269,7 @@
1.19 char *s = __load_via_object(self->value, __pos___data__).strvalue;
1.20 char *o = __load_via_object(other->value, __pos___data__).strvalue;
1.21 int n = strlen(s) + strlen(o) + 1;
1.22 - char *r = calloc(n, sizeof(char));
1.23 + char *r = (char *) __ALLOCATE(n, sizeof(char));
1.24
1.25 strncpy(r, s, n);
1.26 strncpy(r + strlen(s), o, n - strlen(s));
1.27 @@ -340,7 +340,7 @@
1.28 unsigned int n = __load_via_object(size->value, __pos___data__).intvalue;
1.29
1.30 /* Allocate space for the list. */
1.31 - __fragment *data = calloc(1, __FRAGMENT_SIZE(n));
1.32 + __fragment *data = (__fragment *) __ALLOCATE(1, __FRAGMENT_SIZE(n));
1.33 __attr attr = {0, .data=data};
1.34
1.35 /* The initial capacity is the same as the given size. */
1.36 @@ -377,7 +377,7 @@
1.37 {
1.38 /* NOTE: Consider various restrictions on capacity increases. */
1.39 n = capacity ? capacity * 2 : 1;
1.40 - newdata = realloc(data, __FRAGMENT_SIZE(n));
1.41 + newdata = (__fragment *) __REALLOCATE(data, __FRAGMENT_SIZE(n));
1.42 newdata->capacity = n;
1.43 }
1.44
1.45 @@ -407,7 +407,7 @@
1.46 if (size + other_size >= capacity)
1.47 {
1.48 n = size + other_size;
1.49 - newdata = realloc(data, __FRAGMENT_SIZE(n));
1.50 + newdata = (__fragment *) __REALLOCATE(data, __FRAGMENT_SIZE(n));
1.51 newdata->capacity = n;
1.52 }
1.53
1.54 @@ -479,7 +479,7 @@
1.55 size += strlen(__load_via_object(data->attrs[i].value, __pos___data__).strvalue);
1.56
1.57 /* Reserve space for a new string. */
1.58 - s = calloc(size + 1, sizeof(char));
1.59 + s = (char *) __ALLOCATE(size + 1, sizeof(char));
1.60
1.61 /* Build a single string from the buffer contents. */
1.62 for (i = 0, j = 0; i < data->size; i++)