From d04fb041acf6aee5cc19dff8b96e118374536700 Mon Sep 17 00:00:00 2001 From: Raghuram Subramani Date: Sat, 9 Aug 2025 14:12:30 +0530 Subject: engine: eachdo: append one content for each iteration This will be required in the future when priorities are added. --- src/engine/eachdo.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/engine/eachdo.c') diff --git a/src/engine/eachdo.c b/src/engine/eachdo.c index 91a6d3f..1cdd92b 100644 --- a/src/engine/eachdo.c +++ b/src/engine/eachdo.c @@ -45,15 +45,15 @@ write_eachdo_iteration(list_t *atoms, list_t *keys, list_t *values) { + char *content = calloc(1, sizeof(char)); + for (size_t i = 0; i < directives->size; i++) { directive_t *_directive = list_get(directives, i); switch (_directive->type) { case _RAW: { - /* *content = realloc(*content, - strlen(*content) + strlen(_directive->operands) + 1); - strcat(*content, _directive->operands); */ - - list_wrap_and_add(atoms, strdup(_directive->operands)); + content = realloc(content, + strlen(content) + strlen(_directive->operands) + 1); + strcat(content, _directive->operands); break; } @@ -62,10 +62,8 @@ write_eachdo_iteration(list_t *atoms, keys, values, trim(_directive->operands))); if (key != NULL) { - /* *content = realloc(*content, strlen(*content) + strlen(key) + 1); - strcat(*content, key); */ - - list_wrap_and_add(atoms, strdup(key)); + content = realloc(content, strlen(content) + strlen(key) + 1); + strcat(content, key); } break; @@ -76,6 +74,8 @@ write_eachdo_iteration(list_t *atoms, break; } } + + list_wrap_and_add(atoms, content); } /* -- cgit v1.2.3