diff options
Diffstat (limited to 'src/types.c')
-rw-r--r-- | src/types.c | 7 |
1 files changed, 5 insertions, 2 deletions
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("}"); } |