From 8a0bcfe9035266fa29b2440034f9a6e9ce1a6e8f Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Mon, 20 Jul 2020 20:22:09 +0200 Subject: [PATCH] fix a dead wrong call to free(prof_time) --- Makefile | 2 +- libprof.c | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index dc0b9d5..e806cb5 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,6 @@ distclean: clean # Install -install: +install: $(lib) cp $(lib) $(DESTDIR)$(PREFIX) cp $(header) $(DESTDIR)$(PREFIX)/include diff --git a/libprof.c b/libprof.c index 552373a..ab82c0c 100644 --- a/libprof.c +++ b/libprof.c @@ -14,7 +14,7 @@ uint32_t *prof_elapsed = NULL; /* Timer counter */ uint32_t volatile *prof_tcnt = NULL; /* Timer ID */ -static int prof_timer; +static int prof_timer = -1; /* prof_init(): Initialize the profiler's data and timer */ int prof_init(int context_count) @@ -56,10 +56,13 @@ int prof_init(int context_count) /* prof_quit(): Free the profiler's data and timer */ void prof_quit(void) { - timer_stop(prof_timer); + if(prof_timer >= 0) timer_stop(prof_timer); + if(prof_rec) free(prof_rec); + if(prof_elapsed) free(prof_elapsed); - free(prof_rec); - free(prof_time); + prof_timer = -1; + prof_rec = NULL; + prof_elapsed = NULL; } //---