summaryrefslogtreecommitdiff
path: root/src/templating/test6/test-custom-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/templating/test6/test-custom-write.c')
-rw-r--r--src/templating/test6/test-custom-write.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/templating/test6/test-custom-write.c b/src/templating/test6/test-custom-write.c
index cc50a47cb..20042c1ed 100644
--- a/src/templating/test6/test-custom-write.c
+++ b/src/templating/test6/test-custom-write.c
@@ -1,6 +1,5 @@
/*
Author: José Bollo <jobol@nonadev.net>
- Author: José Bollo <jose.bollo@iot.bzh>
https://gitlab.com/jobol/mustach
@@ -17,7 +16,9 @@
limitations under the License.
*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdlib.h>
#include <stdio.h>
@@ -36,7 +37,7 @@ static char *readfile(const char *filename)
{
int f;
struct stat s;
- char *result;
+ char *result, *ptr;
size_t size, pos;
ssize_t rc;
@@ -80,7 +81,10 @@ static char *readfile(const char *filename)
pos += (size_t)rc;
if (pos > size) {
size = pos + BLOCKSIZE;
- result = realloc(result, size + 1);
+ ptr = realloc(result, size + 1);
+ if (!ptr)
+ free(result);
+ result = ptr;
}
}
} while(rc > 0);
@@ -132,7 +136,7 @@ int main(int ac, char **av)
mode = None;
else {
t = readfile(*av);
- s = umustach_json_c(t, o, uwrite, NULL);
+ s = mustach_json_c_write(t, 0, o, Mustach_With_AllExtensions, uwrite, NULL);
if (s != 0)
fprintf(stderr, "Template error %d\n", s);
free(t);