From 7aa1c66d99b0b09aa7832d8378a5e9fc260c33e0 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 14 Mar 2017 11:21:05 -0300 Subject: [PATCH] do not use the sample samples objects in villas-hook as the hooks might add references to keep copies of older samples --- src/hook.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hook.c b/src/hook.c index d74c62e02..0c30b1a8d 100644 --- a/src/hook.c +++ b/src/hook.c @@ -94,10 +94,6 @@ int main(int argc, char *argv[]) if (ret) error("Failed to initilize memory pool"); - ret = sample_alloc(&pool, samples, cnt); - if (ret != cnt) - error("Failed to allocate %u samples from pool", cnt); - h->parameter = parameter; if (h->type & HOOK_INIT) @@ -108,6 +104,10 @@ int main(int argc, char *argv[]) h->cb(h, HOOK_PATH_START, &hi); while (!feof(stdin)) { + ret = sample_alloc(&pool, samples, cnt); + if (ret != cnt) + error("Failed to allocate %u samples from pool", cnt); + for (j = 0; j < cnt && !feof(stdin); j++) sample_fscan(stdin, hi.smps[j], NULL); @@ -122,6 +122,8 @@ int main(int argc, char *argv[]) for (j = 0; j < hi.cnt; j++) sample_fprint(stdout, hi.smps[j], SAMPLE_ALL); + + sample_free(samples, cnt); } if (h->type & HOOK_PATH_STOP)