- commit
- e1e6cc95c33b9b1e5b4200d90116f04b868b7f03
- parent
- 26fa5272e83773d8494fafc8ca842952874dc49f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-12-18 12:47
dynamic free
Diffstat
| M | beat.c | 16 | ++++++++++++---- |
1 files changed, 12 insertions, 4 deletions
diff --git a/beat.c b/beat.c
@@ -106,10 +106,18 @@ int main(int argc, char **argv) {
106 106 add_file_at_beat(path, beat);
107 107 }
108 108
109 -1 _sf_writef_float(outfile, ctx->buf);
110 -1 _sf_writef_float(outfile, ctx->next->buf);
-1 109 struct context *last = ctx;
-1 110 while (last->next != ctx) {
-1 111 last = last->next;
-1 112 }
-1 113 last->next = NULL;
-1 114
-1 115 while (ctx) {
-1 116 struct context *tmp = ctx;
-1 117 _sf_writef_float(outfile, tmp->buf);
-1 118 ctx = tmp->next;
-1 119 free(tmp);
-1 120 }
111 121
112 -1 free(ctx->next);
113 -1 free(ctx);
114 122 sf_close(outfile);
115 123 }