cbase 1.50.0
C/C++ Static Template
Loading...
Searching...
No Matches
Changelog

All notable changes to this project will be documented in this file.


[1.50.0] - 2026-03-19

Added

include/memory/mem_allocator.h

include/base/base_map.h

Changed

include/base/str_builder.h

include/base/base_map.h

test/test_str_builder.c

  • All tests updated: MemArena is still created directly but immediately wrapped with mem_arena_allocator() before being passed to any sb_* function
  • sb_result_in_separate_arena renamed to sb_result_in_separate_alloc to reflect the abstraction
  • mem_arena_clear replaced with mem_free_all in the arena-independence test

test/main.c

  • Updated RUN_TEST call to match renamed sb_result_in_separate_alloc

Fixed

src/CMakeLists.txt

  • GLOB_RECURSE was including main.c in cbase_lib, causing main() to be defined twice at link time. A list(FILTER ... EXCLUDE) now strips any main.c / main.cpp from the library sources before the add_library call

include/base/base_map.h

  • Corrected Arena * parameter type (stale name from an older API) to MemAllocator * in all three allocation-bearing functions

Documentation

include/base/base_strings.h

include/base/base_types.h

  • Added copyright line
  • Added @par Type Naming Convention, @par Why Both s and i Aliases?, and @par Boolean Types sections to the file-level doc
  • isize now documents why ptrdiff_t is used instead of POSIX ssize_t
  • f128 conditional doc now explains it is unavailable on MSVC and that no silent fallback exists

include/base/base_macros.h

  • Added @par Context Detection and @par Macro Categories sections to the file-level doc

include/test/test.h


[1.47.1] - 2026-03-11

Fixed

test/main.c

  • Registered the three missing memory test cases: arena_aligned_push, arena_temp, and arena_allocator_interface were defined but never called - they now run as part of the suite

.gitignore

  • Removed .clang-format from the ignore list so the formatting config is committed and available to all contributors

include/base/base_strings.h

  • Added #include <ctype.h> for tolower used in str8_match_nocase
  • Added #include <string.h> directly (was only arriving transitively via base_macros.h)

include/memory/mem_arena.h

  • Added explicit #include <string.h> since PUSH_CSTR expands to strlen

include/base/base_macros.h

  • AsciiID4: added (u32)(u8) casts on every argument to prevent undefined behaviour from left-shifting a signed or negative char value

Changed

include/memory/mem_gpalloc.h

  • Removed heap-allocated _GpAllocCtx and gpalloc_destroy() - the zero_init flag is now encoded directly into the Allocator.ctx field as a uintptr_t (0 or 1). This eliminates the context allocation, removes the leak footgun, and makes gpalloc_destroy() unnecessary. Existing call sites that called gpalloc_destroy() can simply remove that call.

include/base/base_log.h / src/base/base_log.c

  • Added log_remove_callback(LogFn fn) - unregisters a previously added callback by function pointer, freeing its slot. Must be called before closing a FILE* sink to prevent a dangling pointer.
  • Windows color support: replaced empty-string color stubs with a runtime check that calls SetConsoleMode(ENABLE_VIRTUAL_TERMINAL_PROCESSING) on first use. Colors now work on Windows 10 1511+ consoles and automatically fall back to plain text when output is redirected or the console is older.

src/main.c

  • Added a comment warning that fclose(log_file) must be preceded by removing the registered sink; the old comment was insufficient

[1.47.0] - 2026-03-10

Added

base_strings.h

  • str8_suffix(str, size) - returns the last size bytes; complement to str8_prefix
  • str8_chop(str, amt) - removes the last amt bytes; complement to str8_skip
  • str8_match_nocase(a, b) - case-insensitive equality check (ASCII)
  • str8_starts_with(str, prefix) - returns 1 if str begins with prefix
  • str8_ends_with(str, suffix) - returns 1 if str ends with suffix
  • str8_find_first(str, byte) - returns the index of the first match, or str.size as a not-found sentinel
  • str8_list_push(list, node, str) - inline push for String8List; caller owns the node allocation

test_harness.h

  • EXPECT_FATAL(cond) - like EXPECT but calls abort() immediately on failure; use before any pointer dereference where continuing would be undefined behaviour

Changed

base_strings.h

  • STR8 macro now wraps _Static_assert(__builtin_constant_p(s), ...) on GCC and Clang to catch accidental pointer arguments at compile time; falls back to the plain version on MSVC
  • str8_cstr - replaced manual while loop with strlen
  • str8_substr - replaced the implicit MIN-based inversion guard with an explicit if (clamped_opl < clamped_first) correction for clarity

build.bat / build.sh

  • Added ninja and ninja release targets that invoke CMake with -G "Ninja" and, on Windows, explicitly set CMAKE_C_COMPILER=cl and CMAKE_CXX_COMPILER=cl so the MSVC toolchain is used
  • build.sh gained a clean target (rm -rf build) to match the Windows equivalent

test_memory.c

  • All EXPECT(ptr != NULL) checks on freshly allocated pointers changed to EXPECT_FATAL so a NULL return aborts immediately instead of cascading into a NULL dereference
  • Fixed misleading arena alignment comment: clarified that alignment pads before the current allocation, not after
  • Added EXPECT(grown != old_arr) to arena_allocator_interface - verifies that arena realloc actually returns a new pointer rather than silently passing if the same one came back

test_log.c

  • vsnprintf return value is now checked: EXPECT(r > 0 && r < (int)sizeof(last_msg)) catches truncated log messages in tests instead of silently discarding the result

src/CMakeLists.txt

  • Sources are now compiled into a cbase_lib static library; cbase_app links against it - eliminates the double-compilation that previously existed between the app and test targets

test/CMakeLists.txt

  • Replaced the hardcoded list of ../src/... source files with target_link_libraries(cbase_tests PRIVATE cbase_lib) - new modules are now picked up automatically without manual edits here

Fixed

.gitignore

  • Removed duplicate compile_commands.json entry

CHANGELOG.md

  • Added versioned ## [x.y.z] - date header to the existing unversioned entry so changes can be correlated to releases

[1.46.11] - 2026-03-10

base_macros.h - Added IS_POW2(x) which correctly rejects zero, alongside the existing IS_POW2_OR_ZERO. Use IS_POW2 wherever you're validating an alignment argument.

mem_arena.h

  • ARENA_DEFAULT_ALIGN changed from hardcoded 8 to sizeof(void *) for 32/64-bit portability
  • arena_pop_to docs updated to mention the new debug assert
  • New arena_clear_and_decommit() declaration - resets pos and returns physical RAM to the OS
  • New arena_push_cstr() declaration - copies a string into the arena with NUL termination
  • New PUSH_CSTR(arena, cstr) convenience macro wrapping arena_push_cstr + strlen

mem_arena.c

  • arena_push_internal now uses IS_POW2 instead of IS_POW2_OR_ZERO - alignment of 0 now correctly fires the assert
  • arena_pop_to now asserts pos <= arena->pos in debug builds; still clamps defensively in release
  • arena_clear_and_decommit() implemented - calls os_mem_decommit then zeros both pos and cmt
  • arena_push_cstr() implemented

mem_allocator.h

  • Split the combined &&-style asserts into two separate ASSERT calls with distinct messages
  • Removed _arena_realloc_fn - it was identical to the generic fallback path in allocator_realloc
  • arena_allocator() now sets .realloc = NULL explicitly with a comment explaining why

mem_os.c

  • Added a comment to the Linux os_mem_decommit path explaining MADV_FREE vs MADV_DONTNEED and when you'd want to switch