Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);


Expand Down
12 changes: 2 additions & 10 deletions src/cstring.core.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

/* Standard C header files */

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -78,13 +77,6 @@
#define CSTRING_OFFSET_SIZE (16)


/* /////////////////////////////////////////////////////////////////////////
* debugging
*/

#define CSTRING_ASSERT(expr) assert(expr)


/* /////////////////////////////////////////////////////////////////////////
* character encoding
*/
Expand Down Expand Up @@ -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);
Expand All @@ -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 */
Expand Down
20 changes: 10 additions & 10 deletions src/cstring.vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
/* cstring header files */

#include <cstring/cstring.vector.h>
#include "internal.h"

#ifndef CSTRING_INCL_CSTRING_INTERNAL_H_SAFESTR
# include <cstring/internal/safestr.h>
#endif /* CSTRING_INCL_CSTRING_INTERNAL_H_SAFESTR */

/* Standard C header files */

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion src/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*
Expand Down Expand Up @@ -49,6 +49,8 @@
*/

#include <cstring/cstring.h>
#include "internal.h"

#if !defined(__MWERKS__)
# include <windows.h>
#else /* ? compiler */
Expand Down
35 changes: 28 additions & 7 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cstring/cstring.h>
#include <assert.h>


/* /////////////////////////////////////////////////////////////////////////
* 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*
Expand All @@ -92,7 +113,7 @@ win32_comtask_realloc(
void* pv
, size_t cb
);
#endif /* CSTRING_USE_WINAPI_ */
#endif /* _WIN32 */


/* ////////////////////////////////////////////////////////////////////// */
Expand Down
1 change: 1 addition & 0 deletions src/win.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
* includes
*/

#include <cstring/cstring.h>
#include "internal.h"


Expand Down
Loading