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 82fdf683fbe46d8afa1da8d072152ddce069bb8c
parent d891bff6fc039f15c701e27f3a389ba25eec7b20
Author: Remy Noulin <loader2x@gmail.com>
Date:   Sun, 30 Aug 2020 14:03:44 +0200

fix cleanup for objects declared in local code blocks and fprintf stderr with logE

release/json/libsheepyCSmallArray.h     | 10 +++++++++-
release/json/libsheepyCSmallBool.h      | 10 +++++++++-
release/json/libsheepyCSmallBytes.h     | 10 +++++++++-
release/json/libsheepyCSmallContainer.h | 10 +++++++++-
release/json/libsheepyCSmallDict.h      | 10 +++++++++-
release/json/libsheepyCSmallDouble.h    | 10 +++++++++-
release/json/libsheepyCSmallInt.h       | 10 +++++++++-
release/json/libsheepyCSmallJson.h      | 10 +++++++++-
release/json/libsheepyCSmallString.h    | 10 +++++++++-
release/json/libsheepyCUndefined.h      | 10 +++++++++-
release/libsheepy.c                     | 13 ++++++++-----
release/libsheepy.h                     |  2 +-
src/json/libsheepyCSmallArray.c         |  6 ++++++
src/json/libsheepyCSmallArray.h         | 10 +++++++++-
src/json/libsheepyCSmallBool.c          |  6 ++++++
src/json/libsheepyCSmallBool.h          | 10 +++++++++-
src/json/libsheepyCSmallBytes.c         |  6 ++++++
src/json/libsheepyCSmallBytes.h         | 10 +++++++++-
src/json/libsheepyCSmallContainer.c     |  6 ++++++
src/json/libsheepyCSmallContainer.h     | 10 +++++++++-
src/json/libsheepyCSmallDict.c          |  6 ++++++
src/json/libsheepyCSmallDict.h          | 10 +++++++++-
src/json/libsheepyCSmallDouble.c        |  6 ++++++
src/json/libsheepyCSmallDouble.h        | 10 +++++++++-
src/json/libsheepyCSmallInt.c           |  6 ++++++
src/json/libsheepyCSmallInt.h           | 10 +++++++++-
src/json/libsheepyCSmallJson.c          |  5 +++++
src/json/libsheepyCSmallJson.h          | 10 +++++++++-
src/json/libsheepyCSmallString.c        |  6 ++++++
src/json/libsheepyCSmallString.h        | 10 +++++++++-
src/json/libsheepyCUndefined.c          |  6 ++++++
src/json/libsheepyCUndefined.h          | 10 +++++++++-
src/libsheepy.c                         | 13 ++++++++-----
src/libsheepy.h                         |  2 +-
34 files changed, 257 insertions(+), 32 deletions(-)

Diffstat:
Mrelease/json/libsheepyCSmallArray.h | 10+++++++++-
Mrelease/json/libsheepyCSmallBool.h | 10+++++++++-
Mrelease/json/libsheepyCSmallBytes.h | 10+++++++++-
Mrelease/json/libsheepyCSmallContainer.h | 10+++++++++-
Mrelease/json/libsheepyCSmallDict.h | 10+++++++++-
Mrelease/json/libsheepyCSmallDouble.h | 10+++++++++-
Mrelease/json/libsheepyCSmallInt.h | 10+++++++++-
Mrelease/json/libsheepyCSmallJson.h | 10+++++++++-
Mrelease/json/libsheepyCSmallString.h | 10+++++++++-
Mrelease/json/libsheepyCUndefined.h | 10+++++++++-
Mrelease/libsheepy.c | 13++++++++-----
Mrelease/libsheepy.h | 2+-
Msrc/json/libsheepyCSmallArray.c | 6++++++
Msrc/json/libsheepyCSmallArray.h | 10+++++++++-
Msrc/json/libsheepyCSmallBool.c | 6++++++
Msrc/json/libsheepyCSmallBool.h | 10+++++++++-
Msrc/json/libsheepyCSmallBytes.c | 6++++++
Msrc/json/libsheepyCSmallBytes.h | 10+++++++++-
Msrc/json/libsheepyCSmallContainer.c | 6++++++
Msrc/json/libsheepyCSmallContainer.h | 10+++++++++-
Msrc/json/libsheepyCSmallDict.c | 6++++++
Msrc/json/libsheepyCSmallDict.h | 10+++++++++-
Msrc/json/libsheepyCSmallDouble.c | 6++++++
Msrc/json/libsheepyCSmallDouble.h | 10+++++++++-
Msrc/json/libsheepyCSmallInt.c | 6++++++
Msrc/json/libsheepyCSmallInt.h | 10+++++++++-
Msrc/json/libsheepyCSmallJson.c | 5+++++
Msrc/json/libsheepyCSmallJson.h | 10+++++++++-
Msrc/json/libsheepyCSmallString.c | 6++++++
Msrc/json/libsheepyCSmallString.h | 10+++++++++-
Msrc/json/libsheepyCUndefined.c | 6++++++
Msrc/json/libsheepyCUndefined.h | 10+++++++++-
Msrc/libsheepy.c | 13++++++++-----
Msrc/libsheepy.h | 2+-
34 files changed, 257 insertions(+), 32 deletions(-)

diff --git a/release/json/libsheepyCSmallArray.h b/release/json/libsheepyCSmallArray.h @@ -1844,6 +1844,9 @@ smallArrayt* allocCArraySmallArray(const char **array); // terminate smallArrayt val when it is out of scope void cleanUpSmallArrayTerminateG(smallArrayt **val); +// free smallArrayt local val when it is out of scope +void cleanUpSmallArrayFreeLocalG(smallArrayt *val); + // free smallArrayt val when it is out of scope void cleanUpSmallArrayFreeG(smallArrayt **val); @@ -1869,7 +1872,12 @@ void cleanUpSmallArraySmashG(smallArrayt **val); /** * declare local object name with type smallArrayt and free name when it is out of scope */ -#define cleanSmallArray(name) smallArrayt name CLEANUP(cleanUpSmallArrayFreeG); initiateSmallArray(&name) +#define cleanSmallArray(name) smallArrayt name CLEANUP(cleanUpSmallArrayFreeLocalG); initiateSmallArray(&name) + +/** + * declare pointer name with type smallArrayt and free name when it is out of scope + */ +#define cleanFreeSmallArray(name) smallArrayt *name CLEANUP(cleanUpSmallArrayFreeG) /** * declare pointer name with Type smallArrayt and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallBool.h b/release/json/libsheepyCSmallBool.h @@ -247,6 +247,9 @@ smallBoolt* allocSmallBool(bool value); // terminate smallBoolt val when it is out of scope void cleanUpSmallBoolTerminateG(smallBoolt **val); +// free smallBoolt local val when it is out of scope +void cleanUpSmallBoolFreeLocalG(smallBoolt *val); + // free smallBoolt val when it is out of scope void cleanUpSmallBoolFreeG(smallBoolt **val); @@ -266,7 +269,12 @@ void cleanUpSmallBoolFinishG(smallBoolt **val); /** * declare local object name with type smallBoolt and free name when it is out of scope */ -#define cleanSmallBool(name) smallBoolt name CLEANUP(cleanUpSmallBoolFreeG); initiateSmallBool(&name) +#define cleanSmallBool(name) smallBoolt name CLEANUP(cleanUpSmallBoolFreeLocalG); initiateSmallBool(&name) + +/** + * declare pointer name with type smallBoolt and free name when it is out of scope + */ +#define cleanFreeSmallBool(name) smallBoolt *name CLEANUP(cleanUpSmallBoolFreeG) /** * declare pointer name with Type smallBoolt and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallBytes.h b/release/json/libsheepyCSmallBytes.h @@ -262,6 +262,9 @@ smallBytest* allocSmallBytes(void *data, uint32_t size); // terminate smallBytest val when it is out of scope void cleanUpSmallBytesTerminateG(smallBytest **val); +// free smallBytest val declared locally in a code block when it is out of scope +void cleanUpSmallBytesFreeLocalG(smallBytest *val); + // free smallBytest val when it is out of scope void cleanUpSmallBytesFreeG(smallBytest **val); @@ -281,7 +284,12 @@ void cleanUpSmallBytesFinishG(smallBytest **val); /** * declare local object name with type smallBytest and free name when it is out of scope */ -#define cleanSmallBytes(name) smallBytest name CLEANUP(cleanUpSmallBytesFreeG); initiateSmallBytes(&name) +#define cleanSmallBytes(name) smallBytest name CLEANUP(cleanUpSmallBytesFreeLocalG); initiateSmallBytes(&name) + +/** + * declare pointer name with type smallBytest and free name when it is out of scope + */ +#define cleanFreeSmallBytes(name) smallBytest *name CLEANUP(cleanUpSmallBytesFreeG) /** * declare pointer name with Type smallBytest and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallContainer.h b/release/json/libsheepyCSmallContainer.h @@ -217,6 +217,9 @@ smallContainert* allocSmallContainer(void *data); // terminate smallContainert val when it is out of scope void cleanUpSmallContainerTerminateG(smallContainert **val); +// free smallContainert local val when it is out of scope +void cleanUpSmallContainerFreeLocalG(smallContainert *val); + // free smallContainert val when it is out of scope void cleanUpSmallContainerFreeG(smallContainert **val); @@ -236,7 +239,12 @@ void cleanUpSmallContainerFinishG(smallContainert **val); /** * declare local object name with type smallContainert and free name when it is out of scope */ -#define cleanSmallContainer(name) smallContainert name CLEANUP(cleanUpSmallContainerFreeG); initiateSmallContainer(&name) +#define cleanSmallContainer(name) smallContainert name CLEANUP(cleanUpSmallContainerFreeLocalG); initiateSmallContainer(&name) + +/** + * declare pointer name with type smallContainert and free name when it is out of scope + */ +#define cleanFreeSmallContainer(name) smallContainert *name CLEANUP(cleanUpSmallContainerFreeG) /** * declare pointer name with Type smallContainert and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallDict.h b/release/json/libsheepyCSmallDict.h @@ -1049,6 +1049,9 @@ smallDictt* allocSmallDict(void); // terminate smallDictt val when it is out of scope void cleanUpSmallDictTerminateG(smallDictt **val); +// free smallDictt local val when it is out of scope +void cleanUpSmallDictFreeLocalG(smallDictt *val); + // free smallDictt val when it is out of scope void cleanUpSmallDictFreeG(smallDictt **val); @@ -1074,7 +1077,12 @@ void cleanUpSmallDictSmashG(smallDictt **val); /** * declare local object name with type smallDictt and free name when it is out of scope */ -#define cleanSmallDict(name) smallDictt name CLEANUP(cleanUpSmallDictFreeG); initiateSmallDict(&name) +#define cleanSmallDict(name) smallDictt name CLEANUP(cleanUpSmallDictFreeLocalG); initiateSmallDict(&name) + +/** + * declare pointer name with type smallDictt and free name when it is out of scope + */ +#define cleanFreeSmallDict(name) smallDictt *name CLEANUP(cleanUpSmallDictFreeG) /** * declare pointer name with Type smallDictt and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallDouble.h b/release/json/libsheepyCSmallDouble.h @@ -245,6 +245,9 @@ smallDoublet* allocSmallDouble(double value); // terminate smallDoublet val when it is out of scope void cleanUpSmallDoubleTerminateG(smallDoublet **val); +// free smallDoublet local val when it is out of scope +void cleanUpSmallDoubleFreeLocalG(smallDoublet *val); + // free smallDoublet val when it is out of scope void cleanUpSmallDoubleFreeG(smallDoublet **val); @@ -264,7 +267,12 @@ void cleanUpSmallDoubleFinishG(smallDoublet **val); /** * declare local object name with type smallDoublet and free name when it is out of scope */ -#define cleanSmallDouble(name) smallDoublet name CLEANUP(cleanUpSmallDoubleFreeG); initiateSmallDouble(&name) +#define cleanSmallDouble(name) smallDoublet name CLEANUP(cleanUpSmallDoubleFreeLocalG); initiateSmallDouble(&name) + +/** + * declare pointer name with type smallDoublet and free name when it is out of scope + */ +#define cleanFreeSmallDouble(name) smallDoublet *name CLEANUP(cleanUpSmallDoubleFreeG) /** * declare pointer name with Type smallDoublet and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallInt.h b/release/json/libsheepyCSmallInt.h @@ -247,6 +247,9 @@ smallIntt* allocSmallInt(int64_t value); // terminate smallIntt val when it is out of scope void cleanUpSmallIntTerminateG(smallIntt **val); +// free smallIntt local val when it is out of scope +void cleanUpSmallIntFreeLocalG(smallIntt *val); + // free smallIntt val when it is out of scope void cleanUpSmallIntFreeG(smallIntt **val); @@ -266,7 +269,12 @@ void cleanUpSmallIntFinishG(smallIntt **val); /** * declare local object name with type smallIntt and free name when it is out of scope */ -#define cleanSmallInt(name) smallIntt name CLEANUP(cleanUpSmallIntFreeG); initiateSmallInt(&name) +#define cleanSmallInt(name) smallIntt name CLEANUP(cleanUpSmallIntFreeLocalG); initiateSmallInt(&name) + +/** + * declare pointer name with type smallIntt and free name when it is out of scope + */ +#define cleanFreeSmallInt(name) smallIntt *name CLEANUP(cleanUpSmallIntFreeG) /** * declare pointer name with Type smallIntt and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallJson.h b/release/json/libsheepyCSmallJson.h @@ -3429,6 +3429,9 @@ smallJsont* allocSmallJsonG(smallJsont *self UNUSED); // terminate smallJsont val when it is out of scope void cleanUpSmallJsonTerminateG(smallJsont **val); +// free smallJsont local val when it is out of scope +void cleanUpSmallJsonFreeLocalG(smallJsont *val); + // free smallJsont val when it is out of scope void cleanUpSmallJsonFreeG(smallJsont **val); @@ -3454,7 +3457,12 @@ void cleanUpSmallJsonSmashG(smallJsont **val); /** * declare local object name with Type smallJsont and free name when it is out of scope */ -#define cleanSmallJson(name) smallJsont name CLEANUP(cleanUpSmallJsonFreeG); initiateSmallJson(&name) +#define cleanSmallJson(name) smallJsont name CLEANUP(cleanUpSmallJsonFreeLocalG); initiateSmallJson(&name) + +/** + * declare pointer name with type smallJsont and free name when it is out of scope + */ +#define cleanFreeSmallJson(name) smallJsont *name CLEANUP(cleanUpSmallJsonFreeG) /** * declare pointer name with Type smallJsont and finish name when it is out of scope diff --git a/release/json/libsheepyCSmallString.h b/release/json/libsheepyCSmallString.h @@ -1285,6 +1285,9 @@ smallStringt* allocSmallString(const char *string); // terminate smallStringt val when it is out of scope void cleanUpSmallStringTerminateG(smallStringt **val); +// free smallStringt local val when it is out of scope +void cleanUpSmallStringFreeLocalG(smallStringt *val); + // free smallStringt val when it is out of scope void cleanUpSmallStringFreeG(smallStringt **val); @@ -1304,7 +1307,12 @@ void cleanUpSmallStringFinishG(smallStringt **val); /** * declare local object name with type smallStringt and free name when it is out of scope */ -#define cleanSmallString(name) smallStringt name CLEANUP(cleanUpSmallStringFreeG); initiateSmallString(&name) +#define cleanSmallString(name) smallStringt name CLEANUP(cleanUpSmallStringFreeLocalG); initiateSmallString(&name) + +/** + * declare pointer name with type smallStringt and free name when it is out of scope + */ +#define cleanFreeSmallString(name) smallStringt *name CLEANUP(cleanUpSmallStringFreeG) /** * declare pointer name with Type smallStringt and finish name when it is out of scope diff --git a/release/json/libsheepyCUndefined.h b/release/json/libsheepyCUndefined.h @@ -74,6 +74,9 @@ undefinedt* allocUndefined(void); // terminate undefinedt val when it is out of scope void cleanUpUndefinedTerminateG(undefinedt **val); +// free undefinedt local val when it is out of scope +void cleanUpUndefinedFreeLocalG(undefinedt *val); + // free undefinedt val when it is out of scope void cleanUpUndefinedFreeG(undefinedt **val); @@ -96,7 +99,12 @@ void cleanUpUndefinedSmashG(undefinedt **val); /** * declare local object name with type undefinedt and free name when it is out of scope */ -#define cleanUndefined(name) undefinedt name CLEANUP(cleanUpUndefinedFreeG); initiateUndefined(&name) +#define cleanUndefined(name) undefinedt name CLEANUP(cleanUpUndefinedFreeLocalG); initiateUndefined(&name) + +/** + * declare pointer name with type undefinedt and free name when it is out of scope + */ +#define cleanFreeUndefined(name) undefinedt *name CLEANUP(cleanUpUndefinedFreeG) /** * declare pointer name with Type undefinedt and finish name when it is out of scope diff --git a/release/libsheepy.c b/release/libsheepy.c @@ -6432,27 +6432,30 @@ void shPrintfS(const char *fmt, ...) { /** * sheepy Error printf String - * print to stderr + * print with logE * * when the formating string is NULL, "(null)" is printed * * \param * format string like printf * \return - * print to stderr + * print with logE */ void shEPrintfS(const char *fmt, ...) { va_list pl; if (((libsheepyErrorMask) & logMask)) { if (!fmt) { - fprintf(stderr, "(null)\n"); + logE("(null)\n"); return; } - // print to stderr + // print with logE + char *s = "";; va_start(pl, fmt); - vfprintf(stderr, fmt, pl); + vasprintf(&s, fmt, pl); va_end(pl); + logE(s); + free(s); } } 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 "1.2.3" +#define LIBSHEEPY_VERSION "1.2.3.1" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME diff --git a/src/json/libsheepyCSmallArray.c b/src/json/libsheepyCSmallArray.c @@ -41,6 +41,7 @@ smallArrayt* allocSmallArray(void); smallArrayt* allocArraySmallArray(char **array); smallArrayt* allocCArraySmallArray(const char **array); void cleanUpSmallArrayTerminateG(smallArrayt **val); +void cleanUpSmallArrayFreeLocalG(smallArrayt *val); void cleanUpSmallArrayFreeG(smallArrayt **val); void cleanUpSmallArrayFinishG(smallArrayt **val); void cleanUpSmallArrayDisposeG(smallArrayt **val); @@ -1403,6 +1404,11 @@ void cleanUpSmallArrayTerminateG(smallArrayt **val) { terminateO(*val); } +void cleanUpSmallArrayFreeLocalG(smallArrayt *val) { + + freeO(val); +} + void cleanUpSmallArrayFreeG(smallArrayt **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallArray.h b/src/json/libsheepyCSmallArray.h @@ -1844,6 +1844,9 @@ smallArrayt* allocCArraySmallArray(const char **array); // terminate smallArrayt val when it is out of scope void cleanUpSmallArrayTerminateG(smallArrayt **val); +// free smallArrayt local val when it is out of scope +void cleanUpSmallArrayFreeLocalG(smallArrayt *val); + // free smallArrayt val when it is out of scope void cleanUpSmallArrayFreeG(smallArrayt **val); @@ -1869,7 +1872,12 @@ void cleanUpSmallArraySmashG(smallArrayt **val); /** * declare local object name with type smallArrayt and free name when it is out of scope */ -#define cleanSmallArray(name) smallArrayt name CLEANUP(cleanUpSmallArrayFreeG); initiateSmallArray(&name) +#define cleanSmallArray(name) smallArrayt name CLEANUP(cleanUpSmallArrayFreeLocalG); initiateSmallArray(&name) + +/** + * declare pointer name with type smallArrayt and free name when it is out of scope + */ +#define cleanFreeSmallArray(name) smallArrayt *name CLEANUP(cleanUpSmallArrayFreeG) /** * declare pointer name with Type smallArrayt and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallBool.c b/src/json/libsheepyCSmallBool.c @@ -39,6 +39,7 @@ void finalizeRecycleSmallBool(void *arg UNUSED); void finalizeSmallBool(void); smallBoolt* allocSmallBool(bool value); void cleanUpSmallBoolTerminateG(smallBoolt **val); +void cleanUpSmallBoolFreeLocalG(smallBoolt *val); void cleanUpSmallBoolFreeG(smallBoolt **val); void cleanUpSmallBoolFinishG(smallBoolt **val); internal void freeSmallBool(smallBoolt *self); @@ -238,6 +239,11 @@ void cleanUpSmallBoolTerminateG(smallBoolt **val) { terminateO(*val); } +void cleanUpSmallBoolFreeLocalG(smallBoolt *val) { + + freeO(val); +} + void cleanUpSmallBoolFreeG(smallBoolt **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallBool.h b/src/json/libsheepyCSmallBool.h @@ -247,6 +247,9 @@ smallBoolt* allocSmallBool(bool value); // terminate smallBoolt val when it is out of scope void cleanUpSmallBoolTerminateG(smallBoolt **val); +// free smallBoolt local val when it is out of scope +void cleanUpSmallBoolFreeLocalG(smallBoolt *val); + // free smallBoolt val when it is out of scope void cleanUpSmallBoolFreeG(smallBoolt **val); @@ -266,7 +269,12 @@ void cleanUpSmallBoolFinishG(smallBoolt **val); /** * declare local object name with type smallBoolt and free name when it is out of scope */ -#define cleanSmallBool(name) smallBoolt name CLEANUP(cleanUpSmallBoolFreeG); initiateSmallBool(&name) +#define cleanSmallBool(name) smallBoolt name CLEANUP(cleanUpSmallBoolFreeLocalG); initiateSmallBool(&name) + +/** + * declare pointer name with type smallBoolt and free name when it is out of scope + */ +#define cleanFreeSmallBool(name) smallBoolt *name CLEANUP(cleanUpSmallBoolFreeG) /** * declare pointer name with Type smallBoolt and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallBytes.c b/src/json/libsheepyCSmallBytes.c @@ -39,6 +39,7 @@ void finalizeRecycleSmallBytes(void *arg UNUSED); void finalizeSmallBytes(void); smallBytest* allocSmallBytes(void *data, uint32_t size); void cleanUpSmallBytesTerminateG(smallBytest **val); +void cleanUpSmallBytesFreeLocalG(smallBytest *val); void cleanUpSmallBytesFreeG(smallBytest **val); void cleanUpSmallBytesFinishG(smallBytest **val); internal void freeSmallBytes(smallBytest *self); @@ -206,6 +207,11 @@ void cleanUpSmallBytesTerminateG(smallBytest **val) { terminateO(*val); } +void cleanUpSmallBytesFreeLocalG(smallBytest *val) { + + freeO(val); +} + void cleanUpSmallBytesFreeG(smallBytest **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallBytes.h b/src/json/libsheepyCSmallBytes.h @@ -262,6 +262,9 @@ smallBytest* allocSmallBytes(void *data, uint32_t size); // terminate smallBytest val when it is out of scope void cleanUpSmallBytesTerminateG(smallBytest **val); +// free smallBytest val declared locally in a code block when it is out of scope +void cleanUpSmallBytesFreeLocalG(smallBytest *val); + // free smallBytest val when it is out of scope void cleanUpSmallBytesFreeG(smallBytest **val); @@ -281,7 +284,12 @@ void cleanUpSmallBytesFinishG(smallBytest **val); /** * declare local object name with type smallBytest and free name when it is out of scope */ -#define cleanSmallBytes(name) smallBytest name CLEANUP(cleanUpSmallBytesFreeG); initiateSmallBytes(&name) +#define cleanSmallBytes(name) smallBytest name CLEANUP(cleanUpSmallBytesFreeLocalG); initiateSmallBytes(&name) + +/** + * declare pointer name with type smallBytest and free name when it is out of scope + */ +#define cleanFreeSmallBytes(name) smallBytest *name CLEANUP(cleanUpSmallBytesFreeG) /** * declare pointer name with Type smallBytest and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallContainer.c b/src/json/libsheepyCSmallContainer.c @@ -37,6 +37,7 @@ void finalizeRecycleSmallContainer(void *arg UNUSED); void finalizeSmallContainer(void); smallContainert* allocSmallContainer(void *data); void cleanUpSmallContainerTerminateG(smallContainert **val); +void cleanUpSmallContainerFreeLocalG(smallContainert *val); void cleanUpSmallContainerFreeG(smallContainert **val); void cleanUpSmallContainerFinishG(smallContainert **val); internal void freeSmallContainer(smallContainert *self); @@ -143,6 +144,11 @@ void cleanUpSmallContainerTerminateG(smallContainert **val) { terminateO(*val); } +void cleanUpSmallContainerFreeLocalG(smallContainert *val) { + + freeO(val); +} + void cleanUpSmallContainerFreeG(smallContainert **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallContainer.h b/src/json/libsheepyCSmallContainer.h @@ -217,6 +217,9 @@ smallContainert* allocSmallContainer(void *data); // terminate smallContainert val when it is out of scope void cleanUpSmallContainerTerminateG(smallContainert **val); +// free smallContainert local val when it is out of scope +void cleanUpSmallContainerFreeLocalG(smallContainert *val); + // free smallContainert val when it is out of scope void cleanUpSmallContainerFreeG(smallContainert **val); @@ -236,7 +239,12 @@ void cleanUpSmallContainerFinishG(smallContainert **val); /** * declare local object name with type smallContainert and free name when it is out of scope */ -#define cleanSmallContainer(name) smallContainert name CLEANUP(cleanUpSmallContainerFreeG); initiateSmallContainer(&name) +#define cleanSmallContainer(name) smallContainert name CLEANUP(cleanUpSmallContainerFreeLocalG); initiateSmallContainer(&name) + +/** + * declare pointer name with type smallContainert and free name when it is out of scope + */ +#define cleanFreeSmallContainer(name) smallContainert *name CLEANUP(cleanUpSmallContainerFreeG) /** * declare pointer name with Type smallContainert and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallDict.c b/src/json/libsheepyCSmallDict.c @@ -40,6 +40,7 @@ void finalizeRecycleSmallDict(void *arg UNUSED); void finalizeSmallDict(void); smallDictt* allocSmallDict(void); void cleanUpSmallDictTerminateG(smallDictt **val); +void cleanUpSmallDictFreeLocalG(smallDictt *val); void cleanUpSmallDictFreeG(smallDictt **val); void cleanUpSmallDictFinishG(smallDictt **val); void cleanUpSmallDictDisposeG(smallDictt **val); @@ -976,6 +977,11 @@ void cleanUpSmallDictTerminateG(smallDictt **val) { terminateO(*val); } +void cleanUpSmallDictFreeLocalG(smallDictt *val) { + + freeO(val); +} + void cleanUpSmallDictFreeG(smallDictt **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallDict.h b/src/json/libsheepyCSmallDict.h @@ -1049,6 +1049,9 @@ smallDictt* allocSmallDict(void); // terminate smallDictt val when it is out of scope void cleanUpSmallDictTerminateG(smallDictt **val); +// free smallDictt local val when it is out of scope +void cleanUpSmallDictFreeLocalG(smallDictt *val); + // free smallDictt val when it is out of scope void cleanUpSmallDictFreeG(smallDictt **val); @@ -1074,7 +1077,12 @@ void cleanUpSmallDictSmashG(smallDictt **val); /** * declare local object name with type smallDictt and free name when it is out of scope */ -#define cleanSmallDict(name) smallDictt name CLEANUP(cleanUpSmallDictFreeG); initiateSmallDict(&name) +#define cleanSmallDict(name) smallDictt name CLEANUP(cleanUpSmallDictFreeLocalG); initiateSmallDict(&name) + +/** + * declare pointer name with type smallDictt and free name when it is out of scope + */ +#define cleanFreeSmallDict(name) smallDictt *name CLEANUP(cleanUpSmallDictFreeG) /** * declare pointer name with Type smallDictt and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallDouble.c b/src/json/libsheepyCSmallDouble.c @@ -38,6 +38,7 @@ void finalizeRecycleSmallDouble(void *arg UNUSED); void finalizeSmallDouble(void); smallDoublet* allocSmallDouble(double value); void cleanUpSmallDoubleTerminateG(smallDoublet **val); +void cleanUpSmallDoubleFreeLocalG(smallDoublet *val); void cleanUpSmallDoubleFreeG(smallDoublet **val); void cleanUpSmallDoubleFinishG(smallDoublet **val); internal void freeSmallDouble(smallDoublet *self); @@ -237,6 +238,11 @@ void cleanUpSmallDoubleTerminateG(smallDoublet **val) { terminateO(*val); } +void cleanUpSmallDoubleFreeLocalG(smallDoublet *val) { + + freeO(val); +} + void cleanUpSmallDoubleFreeG(smallDoublet **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallDouble.h b/src/json/libsheepyCSmallDouble.h @@ -245,6 +245,9 @@ smallDoublet* allocSmallDouble(double value); // terminate smallDoublet val when it is out of scope void cleanUpSmallDoubleTerminateG(smallDoublet **val); +// free smallDoublet local val when it is out of scope +void cleanUpSmallDoubleFreeLocalG(smallDoublet *val); + // free smallDoublet val when it is out of scope void cleanUpSmallDoubleFreeG(smallDoublet **val); @@ -264,7 +267,12 @@ void cleanUpSmallDoubleFinishG(smallDoublet **val); /** * declare local object name with type smallDoublet and free name when it is out of scope */ -#define cleanSmallDouble(name) smallDoublet name CLEANUP(cleanUpSmallDoubleFreeG); initiateSmallDouble(&name) +#define cleanSmallDouble(name) smallDoublet name CLEANUP(cleanUpSmallDoubleFreeLocalG); initiateSmallDouble(&name) + +/** + * declare pointer name with type smallDoublet and free name when it is out of scope + */ +#define cleanFreeSmallDouble(name) smallDoublet *name CLEANUP(cleanUpSmallDoubleFreeG) /** * declare pointer name with Type smallDoublet and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallInt.c b/src/json/libsheepyCSmallInt.c @@ -39,6 +39,7 @@ void finalizeRecycleSmallInt(void *arg UNUSED); void finalizeSmallInt(void); smallIntt* allocSmallInt(int64_t value); void cleanUpSmallIntTerminateG(smallIntt **val); +void cleanUpSmallIntFreeLocalG(smallIntt *val); void cleanUpSmallIntFreeG(smallIntt **val); void cleanUpSmallIntFinishG(smallIntt **val); internal void freeSmallInt(smallIntt *self); @@ -243,6 +244,11 @@ void cleanUpSmallIntTerminateG(smallIntt **val) { terminateO(*val); } +void cleanUpSmallIntFreeLocalG(smallIntt *val) { + + freeO(val); +} + void cleanUpSmallIntFreeG(smallIntt **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallInt.h b/src/json/libsheepyCSmallInt.h @@ -247,6 +247,9 @@ smallIntt* allocSmallInt(int64_t value); // terminate smallIntt val when it is out of scope void cleanUpSmallIntTerminateG(smallIntt **val); +// free smallIntt local val when it is out of scope +void cleanUpSmallIntFreeLocalG(smallIntt *val); + // free smallIntt val when it is out of scope void cleanUpSmallIntFreeG(smallIntt **val); @@ -266,7 +269,12 @@ void cleanUpSmallIntFinishG(smallIntt **val); /** * declare local object name with type smallIntt and free name when it is out of scope */ -#define cleanSmallInt(name) smallIntt name CLEANUP(cleanUpSmallIntFreeG); initiateSmallInt(&name) +#define cleanSmallInt(name) smallIntt name CLEANUP(cleanUpSmallIntFreeLocalG); initiateSmallInt(&name) + +/** + * declare pointer name with type smallIntt and free name when it is out of scope + */ +#define cleanFreeSmallInt(name) smallIntt *name CLEANUP(cleanUpSmallIntFreeG) /** * declare pointer name with Type smallIntt and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallJson.c b/src/json/libsheepyCSmallJson.c @@ -48,6 +48,7 @@ void finalizeRecycleSmallJson(void *arg UNUSED); void finalizeSmallJson(void); smallJsont* allocSmallJson(void); void cleanUpSmallJsonTerminateG(smallJsont **val); +void cleanUpSmallJsonFreeLocalG(smallJsont *val); void cleanUpSmallJsonFreeG(smallJsont **val); void cleanUpSmallJsonFinishG(smallJsont **val); void cleanUpSmallJsonDisposeG(smallJsont **val); @@ -2604,6 +2605,10 @@ void cleanUpSmallJsonTerminateG(smallJsont **val) { terminateO(*val); } +void cleanUpSmallJsonFreeLocalG(smallJsont *val) { + + freeO(val); +} void cleanUpSmallJsonFreeG(smallJsont **val) { diff --git a/src/json/libsheepyCSmallJson.h b/src/json/libsheepyCSmallJson.h @@ -3429,6 +3429,9 @@ smallJsont* allocSmallJsonG(smallJsont *self UNUSED); // terminate smallJsont val when it is out of scope void cleanUpSmallJsonTerminateG(smallJsont **val); +// free smallJsont local val when it is out of scope +void cleanUpSmallJsonFreeLocalG(smallJsont *val); + // free smallJsont val when it is out of scope void cleanUpSmallJsonFreeG(smallJsont **val); @@ -3454,7 +3457,12 @@ void cleanUpSmallJsonSmashG(smallJsont **val); /** * declare local object name with Type smallJsont and free name when it is out of scope */ -#define cleanSmallJson(name) smallJsont name CLEANUP(cleanUpSmallJsonFreeG); initiateSmallJson(&name) +#define cleanSmallJson(name) smallJsont name CLEANUP(cleanUpSmallJsonFreeLocalG); initiateSmallJson(&name) + +/** + * declare pointer name with type smallJsont and free name when it is out of scope + */ +#define cleanFreeSmallJson(name) smallJsont *name CLEANUP(cleanUpSmallJsonFreeG) /** * declare pointer name with Type smallJsont and finish name when it is out of scope diff --git a/src/json/libsheepyCSmallString.c b/src/json/libsheepyCSmallString.c @@ -42,6 +42,7 @@ void finalizeRecycleSmallString(void *arg UNUSED); void finalizeSmallString(void); smallStringt* allocSmallString(const char *string); void cleanUpSmallStringTerminateG(smallStringt **val); +void cleanUpSmallStringFreeLocalG(smallStringt *val); void cleanUpSmallStringFreeG(smallStringt **val); void cleanUpSmallStringFinishG(smallStringt **val); smallStringt* createSF(const char *paramType, ...); @@ -828,6 +829,11 @@ void cleanUpSmallStringTerminateG(smallStringt **val) { terminateO(*val); } +void cleanUpSmallStringFreeLocalG(smallStringt *val) { + + freeO(val); +} + void cleanUpSmallStringFreeG(smallStringt **val) { freeO(*val); diff --git a/src/json/libsheepyCSmallString.h b/src/json/libsheepyCSmallString.h @@ -1285,6 +1285,9 @@ smallStringt* allocSmallString(const char *string); // terminate smallStringt val when it is out of scope void cleanUpSmallStringTerminateG(smallStringt **val); +// free smallStringt local val when it is out of scope +void cleanUpSmallStringFreeLocalG(smallStringt *val); + // free smallStringt val when it is out of scope void cleanUpSmallStringFreeG(smallStringt **val); @@ -1304,7 +1307,12 @@ void cleanUpSmallStringFinishG(smallStringt **val); /** * declare local object name with type smallStringt and free name when it is out of scope */ -#define cleanSmallString(name) smallStringt name CLEANUP(cleanUpSmallStringFreeG); initiateSmallString(&name) +#define cleanSmallString(name) smallStringt name CLEANUP(cleanUpSmallStringFreeLocalG); initiateSmallString(&name) + +/** + * declare pointer name with type smallStringt and free name when it is out of scope + */ +#define cleanFreeSmallString(name) smallStringt *name CLEANUP(cleanUpSmallStringFreeG) /** * declare pointer name with Type smallStringt and finish name when it is out of scope diff --git a/src/json/libsheepyCUndefined.c b/src/json/libsheepyCUndefined.c @@ -36,6 +36,7 @@ void finalizeRecycleUndefined(void *arg UNUSED); void finalizeUndefined(void); undefinedt* allocUndefined(void); void cleanUpUndefinedTerminateG(undefinedt **val); +void cleanUpUndefinedFreeLocalG(undefinedt *val); void cleanUpUndefinedFreeG(undefinedt **val); void cleanUpUndefinedFinishG(undefinedt **val); void cleanUpUndefinedSmashG(undefinedt **val); @@ -108,6 +109,11 @@ void cleanUpUndefinedTerminateG(undefinedt **val) { terminateO(*val); } +void cleanUpUndefinedFreeLocalG(undefinedt *val) { + + freeO(val); +} + void cleanUpUndefinedFreeG(undefinedt **val) { freeO(*val); diff --git a/src/json/libsheepyCUndefined.h b/src/json/libsheepyCUndefined.h @@ -74,6 +74,9 @@ undefinedt* allocUndefined(void); // terminate undefinedt val when it is out of scope void cleanUpUndefinedTerminateG(undefinedt **val); +// free undefinedt local val when it is out of scope +void cleanUpUndefinedFreeLocalG(undefinedt *val); + // free undefinedt val when it is out of scope void cleanUpUndefinedFreeG(undefinedt **val); @@ -96,7 +99,12 @@ void cleanUpUndefinedSmashG(undefinedt **val); /** * declare local object name with type undefinedt and free name when it is out of scope */ -#define cleanUndefined(name) undefinedt name CLEANUP(cleanUpUndefinedFreeG); initiateUndefined(&name) +#define cleanUndefined(name) undefinedt name CLEANUP(cleanUpUndefinedFreeLocalG); initiateUndefined(&name) + +/** + * declare pointer name with type undefinedt and free name when it is out of scope + */ +#define cleanFreeUndefined(name) undefinedt *name CLEANUP(cleanUpUndefinedFreeG) /** * declare pointer name with Type undefinedt and finish name when it is out of scope diff --git a/src/libsheepy.c b/src/libsheepy.c @@ -6488,27 +6488,30 @@ void shPrintfS(const char *fmt, ...) { /** * sheepy Error printf String - * print to stderr + * print with logE * * when the formating string is NULL, "(null)" is printed * * \param * format string like printf * \return - * print to stderr + * print with logE */ void shEPrintfS(const char *fmt, ...) { va_list pl; if (((libsheepyErrorMask) & logMask)) { if (!fmt) { - fprintf(stderr, "(null)\n"); + logE("(null)\n"); return; } - // print to stderr + // print with logE + char *s = "";; va_start(pl, fmt); - vfprintf(stderr, fmt, pl); + vasprintf(&s, fmt, pl); va_end(pl); + logE(s); + free(s); } } 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 "1.2.3" +#define LIBSHEEPY_VERSION "1.2.3.1" #ifndef SH_PREFIX #define SH_PREFIX(NAME) NAME