From 51d16373fbaa027e91f230a7423ebb1b2d339042 Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Sun, 23 Oct 2022 21:05:57 +0300 Subject: More --- src/types.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/types.c') diff --git a/src/types.c b/src/types.c index 68c402c..8debe70 100644 --- a/src/types.c +++ b/src/types.c @@ -74,6 +74,7 @@ new_step(recipe * r) if (!r->s[r->sn]) die("Couldn't allocate memory for step"); r->s[r->sn]->inst = NULL; + r->s[r->sn]->txt = NULL; r->s[r->sn]->duration = NULL; r->s[r->sn]->result = NULL; r->s[r->sn]->type = 0; @@ -87,6 +88,8 @@ free_step(step * s) return; if (s->inst) free(s->inst); + if (s->txt) + free(s->txt); if (s->duration) free(s->duration); if (s->result) @@ -220,8 +223,8 @@ tojson(recipe * r) printf(",\"steps\":["); int i = 0; for (; i < r->sn - 1; i++) - printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"},", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); - printf("{\"inst\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"}]", r->s[i]->inst, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); + printf("{\"inst\":\"%s\",\"txt\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"},", r->s[i]->inst, r->s[i]->txt, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); + printf("{\"inst\":\"%s\",\"txt\":\"%s\",\"duration\":\"%s\",\"result\":\"%s\",\"type\":\"%s\"}]", r->s[i]->inst, r->s[i]->txt, r->s[i]->duration, r->s[i]->result, r->s[i]->type == 0 ? "prep" : (r->s[i]->type == 1 ? "cook" : "serve") ); } printf("}"); } -- cgit v1.2.3