From 10b14a90a32e65d9dcbde3eed96183a3993d4c46 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 23 Sep 2021 10:38:44 +0200 Subject: [PATCH] Allocate the traces in the heap --- dump.c | 20 +++++++++++++++----- ovni2prv.c | 8 +++++++- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/dump.c b/dump.c index 2341fec..703f273 100644 --- a/dump.c +++ b/dump.c @@ -126,7 +126,15 @@ void dump_events(struct ovni_trace *trace) int main(int argc, char *argv[]) { char *tracedir; - struct ovni_trace trace; + struct ovni_trace *trace; + + trace = calloc(1, sizeof(struct ovni_trace)); + + if(trace == NULL) + { + perror("calloc"); + exit(EXIT_FAILURE); + } if(argc != 2) { @@ -136,15 +144,17 @@ int main(int argc, char *argv[]) tracedir = argv[1]; - if(ovni_load_trace(&trace, tracedir)) + if(ovni_load_trace(trace, tracedir)) return 1; - if(ovni_load_streams(&trace)) + if(ovni_load_streams(trace)) return 1; - dump_events(&trace); + dump_events(trace); - ovni_free_streams(&trace); + ovni_free_streams(trace); + + free(trace); return 0; } diff --git a/ovni2prv.c b/ovni2prv.c index fd67177..e74b758 100644 --- a/ovni2prv.c +++ b/ovni2prv.c @@ -102,7 +102,13 @@ void dump_events(struct ovni_trace *trace) int main(int argc, char *argv[]) { char *tracedir; - struct ovni_trace *trace = malloc(sizeof(struct ovni_trace)); + struct ovni_trace *trace = calloc(1, sizeof(struct ovni_trace)); + + if(trace == NULL) + { + perror("calloc"); + exit(EXIT_FAILURE); + } if(argc != 2) {