diff --git a/TODO.md b/TODO.md index a6c3bf2..4f1564b 100644 --- a/TODO.md +++ b/TODO.md @@ -15,7 +15,7 @@ * [x] ~~~Delete Visual Studio 98 files~~~ - ✅; * [x] ~~~Delete Visual Studio 2003+ files~~~ - ✅; * [x] ~~~discriminate on `_WIN32` in implementation (and maybe also in API)~~~ - ✅; -* [ ] check `CSTRING_USE_WINAPI_`; +* [x] ~~~check `CSTRING_USE_WINAPI_`~~~; * [ ] custom arena(s); diff --git a/src/cstring.core.c b/src/cstring.core.c index b7668dd..b00bdec 100644 --- a/src/cstring.core.c +++ b/src/cstring.core.c @@ -59,7 +59,6 @@ /* Standard C header files */ -#include #include #include #include @@ -78,13 +77,6 @@ #define CSTRING_OFFSET_SIZE (16) -/* ///////////////////////////////////////////////////////////////////////// - * debugging - */ - -#define CSTRING_ASSERT(expr) assert(expr) - - /* ///////////////////////////////////////////////////////////////////////// * character encoding */ @@ -302,7 +294,7 @@ cstring_realloc_2_( pvNew = realloc(pv, cb); break; -#if defined(CSTRING_USE_WINAPI_) +#ifdef _WIN32 case CSTRING_F_USE_WINDOWS_GLOBAL_MEMORY: pvNew = win32_global_realloc(pv, cb); @@ -315,7 +307,7 @@ cstring_realloc_2_( pvNew = win32_comtask_realloc(pv, cb); break; -#endif /* CSTRING_USE_WINAPI_ */ +#endif /* _WIN32 */ #if defined(CSTRING_USE_SYNESIS_APIS) case CSTRING_F_USE_SYNESIS_HATOR: #endif /* CSTRING_USE_SYNESIS_APIS */ diff --git a/src/cstring.vector.c b/src/cstring.vector.c index 59152c8..81f43ed 100644 --- a/src/cstring.vector.c +++ b/src/cstring.vector.c @@ -51,6 +51,7 @@ /* cstring header files */ #include +#include "internal.h" #ifndef CSTRING_INCL_CSTRING_INTERNAL_H_SAFESTR # include @@ -58,7 +59,6 @@ /* Standard C header files */ -#include #include #include #include @@ -114,7 +114,7 @@ cstring_vector_init( , size_t minCapacity ) { - CSTRING_VECTOR_ASSERT(NULL != pcsv); + CSTRING_ASSERT(NULL != pcsv); if (cstring_vector_DEFAULT_CAPACITY == minCapacity) { @@ -158,7 +158,7 @@ cstring_vector_destroy( CSTRING_RC rc = CSTRING_RC_SUCCESS; size_t i; - CSTRING_VECTOR_ASSERT(NULL != pcsv); + CSTRING_ASSERT(NULL != pcsv); for (i = 0; i != pcsv->len; ++i) { @@ -190,8 +190,8 @@ cstring_vector_truncate( CSTRING_RC rc = CSTRING_RC_SUCCESS; size_t i; - CSTRING_VECTOR_ASSERT(NULL != pcsv); - CSTRING_VECTOR_ASSERT(len <= pcsv->len); + CSTRING_ASSERT(NULL != pcsv); + CSTRING_ASSERT(len <= pcsv->len); for (i = len; i != pcsv->len; ++i) { @@ -215,7 +215,7 @@ cstring_vector_create( , size_t initialSize ) { - CSTRING_VECTOR_ASSERT(NULL != pcsv); + CSTRING_ASSERT(NULL != pcsv); if (cstring_vector_DEFAULT_CAPACITY == initialSize) { @@ -229,7 +229,7 @@ cstring_vector_create( { size_t i; - CSTRING_VECTOR_ASSERT(pcsv->capacity >= initialSize); + CSTRING_ASSERT(pcsv->capacity >= initialSize); for (i = 0; i != initialSize; ++i) { @@ -272,8 +272,8 @@ cstring_vector_insertAt( , size_t numStrings ) { - CSTRING_VECTOR_ASSERT(NULL != pcsv); - CSTRING_VECTOR_ASSERT(NULL != strings || 0 == numStrings); + CSTRING_ASSERT(NULL != pcsv); + CSTRING_ASSERT(NULL != strings || 0 == numStrings); if (0 == numStrings) { @@ -373,7 +373,7 @@ cstring_vector_readLines( size_t numLinesRead_; size_t initialLen; - CSTRING_VECTOR_ASSERT(NULL != pcsv); + CSTRING_ASSERT(NULL != pcsv); initialLen = pcsv->len; diff --git a/src/dllmain.c b/src/dllmain.c index 382b994..432a924 100644 --- a/src/dllmain.c +++ b/src/dllmain.c @@ -4,7 +4,7 @@ * Purpose: Definition of DllMain for the Win32 platform * * Created: 19th August 2005 - * Updated: 2nd August 2026 + * Updated: 29th September 2026 * * Home: http://synesis.com.au/software/ * @@ -49,6 +49,8 @@ */ #include +#include "internal.h" + #if !defined(__MWERKS__) # include #else /* ? compiler */ diff --git a/src/internal.h b/src/internal.h index c4f1c69..74cb2a4 100644 --- a/src/internal.h +++ b/src/internal.h @@ -48,29 +48,50 @@ #define CSTRING_INCL_SRC_H_INTERNAL +/* ///////////////////////////////////////////////////////////////////////// + * checks + */ + +#ifndef CSTRING_INCL_CSTRING_H_CSTRING +# error cstring/cstring.h must be included before this file +#endif /* !CSTRING_INCL_CSTRING_H_CSTRING */ + + /* ///////////////////////////////////////////////////////////////////////// * includes */ -#include +#include /* ///////////////////////////////////////////////////////////////////////// * constants & definitions */ -#if defined(WIN32) || \ - defined(WIN64) -# define CSTRING_USE_WINAPI_ -#endif /* WIN32 || WIN64 */ +/* ///////////////////////////////////////////////////////////////////////// + * macros + */ + + +/* ///////////////////////////////////////////////////////// + * constract enforcements + */ + +#define CSTRING_ASSERT(expr) assert(expr) /* ///////////////////////////////////////////////////////////////////////// + * internal functions + */ + + + +/* ///////////////////////////////////////////////////////// * Windows arena allocators */ -#if defined(CSTRING_USE_WINAPI_) +#ifdef _WIN32 CSTRING_EXTERN_C void* @@ -92,7 +113,7 @@ win32_comtask_realloc( void* pv , size_t cb ); -#endif /* CSTRING_USE_WINAPI_ */ +#endif /* _WIN32 */ /* ////////////////////////////////////////////////////////////////////// */ diff --git a/src/win.c b/src/win.c index 2490256..1d07a52 100644 --- a/src/win.c +++ b/src/win.c @@ -48,6 +48,7 @@ * includes */ +#include #include "internal.h"