Allocate the traces in the heap

This commit is contained in:
Rodrigo Arias 2021-09-23 10:38:44 +02:00
parent 6a3ea0907a
commit 10b14a90a3
2 changed files with 22 additions and 6 deletions

20
dump.c
View File

@ -126,7 +126,15 @@ void dump_events(struct ovni_trace *trace)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *tracedir; 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) if(argc != 2)
{ {
@ -136,15 +144,17 @@ int main(int argc, char *argv[])
tracedir = argv[1]; tracedir = argv[1];
if(ovni_load_trace(&trace, tracedir)) if(ovni_load_trace(trace, tracedir))
return 1; return 1;
if(ovni_load_streams(&trace)) if(ovni_load_streams(trace))
return 1; return 1;
dump_events(&trace); dump_events(trace);
ovni_free_streams(&trace); ovni_free_streams(trace);
free(trace);
return 0; return 0;
} }

View File

@ -102,7 +102,13 @@ void dump_events(struct ovni_trace *trace)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *tracedir; 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) if(argc != 2)
{ {