From a69753dac407e1269c35b81b2e899243c8652e53 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 2 Aug 2021 00:16:09 -0400 Subject: [PATCH] demacroize ncplot_destroy() #1976 --- CMakeLists.txt | 2 +- src/lib/plot.c | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 906dcd5a9..3c1d30681 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,7 @@ endif() # global compiler flags add_compile_definitions(_FORTIFY_SOURCE=2) add_compile_options(-Wall -Wextra -W -Wshadow -Wformat -Wformat-security - -fexceptions -fstrict-aliasing) + -fexceptions -fstrict-aliasing -fanalyzer) message(STATUS "Requested multimedia engine: ${USE_MULTIMEDIA}") message(STATUS "Requested build mode: ${CMAKE_BUILD_TYPE}") diff --git a/src/lib/plot.c b/src/lib/plot.c index b4cb1565f..a18d1958e 100644 --- a/src/lib/plot.c +++ b/src/lib/plot.c @@ -373,16 +373,17 @@ int sample_##T(const nc##X##plot* ncp, int64_t x, T* y){ \ } \ *y = ncp->slots[x % ncp->plot.slotcount]; \ return 0; \ -} \ -void destroy_##T(nc##X##plot* ncpp){ \ - free(ncpp->plot.title); \ - free(ncpp->slots); \ - ncplane_destroy(ncpp->plot.ncp); \ } CREATE(uint64_t, u) CREATE(double, d) +static void +ncplot_destroy(ncplot* n){ + free(n->title); + ncplane_destroy(n->ncp); +} + /* if we're doing domain detection, update the domain to reflect the value we just set. if we're not, check the result against the known ranges, and return -1 if the value is outside of that range. */ @@ -484,7 +485,8 @@ int ncuplot_set_sample(ncuplot* n, uint64_t x, uint64_t y){ void ncuplot_destroy(ncuplot* n){ if(n){ - destroy_uint64_t(n); + ncplot_destroy(&n->plot); + free(n->slots); free(n); } } @@ -533,7 +535,8 @@ int ncdplot_sample(const ncdplot* n, uint64_t x, double* y){ void ncdplot_destroy(ncdplot* n) { if(n){ - destroy_double(n); + ncplot_destroy(&n->plot); + free(n->slots); free(n); } }