libsheepy

C lib for handling text files, strings and json like data structure with an object oriented system
git clone https://spartatek.se/git/libsheepy.git
Log | Files | Refs | README | LICENSE

commit 6497a590ac1cc8da890c34a5a0b779f6bc970ae7
parent 2bbdc6df7a430b294384a5daa6f0ebcba3207f23
Author: Remy Noulin <loader2x@gmail.com>
Date:   Thu, 21 Sep 2023 12:51:19 +0200

add cleanVoidP to free void* when it is out of scope

release/libsheepy.c |  7 +++++++
release/libsheepy.h | 10 +++++++++-
src/libsheepy.c     |  7 +++++++
src/libsheepy.h     | 10 +++++++++-
4 files changed, 32 insertions(+), 2 deletions(-)

Diffstat:
Mrelease/libsheepy.c | 7+++++++
Mrelease/libsheepy.h | 10+++++++++-
Msrc/libsheepy.c | 7+++++++
Msrc/libsheepy.h | 10+++++++++-
4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/release/libsheepy.c b/release/libsheepy.c @@ -81,6 +81,7 @@ internal void segfault_sigaction(int signal UNUSED, siginfo_t *si UNUSED, void * #endif void cleanUpCharFree(char **val); void cleanUpListFree(char* **val); +void cleanUpVoidFree(void **val); void cleanUpFileFree(FILE **val); void cleanUpFd(int *val); uint64_t shStopwatch(uint8_t op); @@ -928,6 +929,12 @@ void cleanUpListFree(char* **val) { } +void cleanUpVoidFree(void **val) { + + free(*val); +} + + void cleanUpFileFree(FILE **val) { if ((*val)) { diff --git a/release/libsheepy.h b/release/libsheepy.h @@ -98,7 +98,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "2.2.12.2" +#define LIBSHEEPY_VERSION "2.2.13" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME @@ -722,6 +722,14 @@ void cleanUpListFree(char*** val); #define cleanListP(name) char **name CLEANUP(cleanUpListFree) // free val when it is out of scope +void cleanUpVoidFree(void **val); + +/** + * declare pointer name with type void* and free name when it is out of scope + */ +#define cleanVoidP(name) void *name CLEANUP(cleanUpVoidFree) + +// free val when it is out of scope void cleanUpFileFree(FILE **val); /** diff --git a/src/libsheepy.c b/src/libsheepy.c @@ -83,6 +83,7 @@ internal void segfault_sigaction(int signal UNUSED, siginfo_t *si UNUSED, void * #endif void cleanUpCharFree(char **val); void cleanUpListFree(char* **val); +void cleanUpVoidFree(void **val); void cleanUpFileFree(FILE **val); void cleanUpFd(int *val); uint64_t shStopwatch(uint8_t op); @@ -984,6 +985,12 @@ void cleanUpListFree(char* **val) { } +void cleanUpVoidFree(void **val) { + + free(*val); +} + + void cleanUpFileFree(FILE **val) { if ((*val)) { diff --git a/src/libsheepy.h b/src/libsheepy.h @@ -98,7 +98,7 @@ // version accoring to the version package: Release.Major.minor.patch // https://noulin.net/version/file/README.md.html -#define LIBSHEEPY_VERSION "2.2.12.2" +#define LIBSHEEPY_VERSION "2.2.13" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME @@ -722,6 +722,14 @@ void cleanUpListFree(char*** val); #define cleanListP(name) char **name CLEANUP(cleanUpListFree) // free val when it is out of scope +void cleanUpVoidFree(void **val); + +/** + * declare pointer name with type void* and free name when it is out of scope + */ +#define cleanVoidP(name) void *name CLEANUP(cleanUpVoidFree) + +// free val when it is out of scope void cleanUpFileFree(FILE **val); /**