Skip to content

Releases: edadma/dynamic_string.h

v0.3.1: Enhanced StringBuilder Operations

29 Aug 11:32

Choose a tag to compare

Enhanced StringBuilder with Advanced String Building Operations

This release significantly expands the StringBuilder API with powerful new functions for efficient string construction.

New StringBuilder Functions

Formatting Functions:

  • ds_builder_append_format() - Printf-style formatting directly into StringBuilder
  • ds_builder_append_format_v() - Va_list version for wrapper functions

Numeric Append Functions:

  • ds_builder_append_int() - Append integer values
  • ds_builder_append_uint() - Append unsigned integer values
  • ds_builder_append_long() - Append long values
  • ds_builder_append_double() - Append double values with precision control

Buffer Operations:

  • ds_builder_append_length() - Append specific number of bytes
  • ds_builder_prepend() - Prepend text to beginning
  • ds_builder_replace_range() - Replace substring within builder

Content Manipulation:

  • ds_builder_remove_range() - Remove characters from builder

Key Features

  • Efficient Construction: Build complex strings without intermediate allocations
  • Printf Integration: Format directly into StringBuilder without temporary strings
  • Precision Control: Full control over numeric formatting and precision
  • Advanced Editing: In-place text manipulation and replacement
  • Complete Documentation: Full Doxygen documentation for all new functions
  • Comprehensive Testing: 77 unit tests covering all functionality

Example Usage

ds_builder sb = ds_builder_create();
ds_builder_append_format(sb, "Processing %d items:\n", 1000);
for (int i = 0; i < 1000; i++) {
    ds_builder_append_format(sb, "Item %d: ", i);
    ds_builder_append_double(sb, i * 3.14, 2);
    ds_builder_append(sb, "\n");
}
ds_string result = ds_builder_to_string(sb);
ds_builder_release(&sb);

Compatibility

All existing code continues to work unchanged. The new functions extend the StringBuilder API without breaking changes.

Assets

  • dynamic_string.h - Complete single-header library (download and include in your project)

v0.3.0: Major API improvement - Reference-counted ds_builder

29 Aug 02:38

Choose a tag to compare

Major API Changes

This release introduces significant improvements to the ds_builder API with reference counting for better memory management.

BREAKING CHANGES

  • Renamed ds_stringbuilder to ds_builder for consistency
  • Changed ds_builder to be heap-allocated and reference-counted like ds_string
  • Replaced ds_builder_destroy() with ds_builder_release() that sets pointer to NULL
  • Updated builder functions to take ds_builder (pointer) instead of ds_builder*

NEW FEATURES

  • Added ds_builder_retain() for safe sharing of builders between different parts of code
  • Improved consistent retain/release semantics across both ds_string and ds_builder
  • Enhanced memory management with full reference counting for builders

Migration Guide

Before v0.3.0:

ds_stringbuilder sb = ds_builder_create();
ds_builder_append(&sb, "Hello");
ds_builder_destroy(&sb);

v0.3.0 and later:

ds_builder sb = ds_builder_create();
ds_builder_append(sb, "Hello");
ds_builder_release(&sb);  // sb becomes NULL

Download

All tests pass (71/71) and the library maintains full backwards compatibility for ds_string operations.

v0.2.2

27 Aug 10:06

Choose a tag to compare

Breaking Changes

NULL Parameter Handling: All functions now assert on NULL ds_string parameters instead of handling them gracefully. This provides immediate error detection and prevents silent failures.

API Changes

  • All ds_string parameters must be non-NULL (functions will assert otherwise)
  • Clear assertion messages specify exactly which parameter caused the failure
  • Maintains 100% backward compatibility for valid (non-NULL) usage patterns

Benefits

  • Immediate error detection - bugs are caught at the source
  • Consistent behavior - all functions handle NULL parameters uniformly
  • Development safety - prevents undefined behavior and silent failures
  • Clear diagnostics - assertion messages pinpoint the exact issue

Migration

  • Code passing valid (non-NULL) parameters continues to work unchanged
  • Code relying on graceful NULL handling will trigger assertions
  • Use debugger or assertion handler to identify and fix NULL parameter usage

Testing

  • Comprehensive assertion testing framework implemented
  • All 71 tests pass with new error handling
  • Zero regressions in functionality

v0.2.1 - Critical Security and Stability Fixes

23 Aug 16:58

Choose a tag to compare

Critical Security and Stability Fixes

This patch release addresses critical vulnerabilities and stability issues discovered in v0.2.0:

Security Fixes

  • Buffer overflow vulnerability in ds_create_length() - now correctly handles requested length vs source string length
  • Comprehensive NULL parameter validation - added assertions for ds_create_length(), ds_prepend(), ds_insert(), ds_substring(), ds_replace(), and ds_replace_all()

Stability Fixes

  • Segmentation fault in test suite caused by dangerous NULL parameter testing
  • API consistency - ds_insert() beyond-bounds behavior now inserts at string end instead of returning unchanged
  • Test suite reliability - corrected 6 failing tests that had incorrect expectations

Testing

  • All 73 tests now pass with proper validation
  • Functions fail fast with clear assertion messages instead of silent undefined behavior

Recommendation

Immediate upgrade recommended for all v0.2.0 users due to the security vulnerabilities.

Compatibility

This is a patch release - no breaking changes to the public API.

v0.2.0: High-Impact String Functions & Atomic Reference Counting

23 Aug 15:48

Choose a tag to compare

New Functions

  • ds_contains() - Clean boolean check for substring presence
  • ds_find_last() - Find last occurrence of substring
  • ds_hash() - FNV-1a hash function for use in hash tables
  • ds_compare_ignore_case() - Case-insensitive string comparison
  • ds_truncate() - Smart truncation with optional ellipsis
  • ds_format_v() - va_list version for wrapper functions
  • ds_escape_json() / ds_unescape_json() - JSON string escaping

Major Features

  • Atomic Reference Counting: Enable with DS_ATOMIC_REFCOUNT=1 for safe concurrent reference sharing
  • Builder Optimizations: All complex string operations now use StringBuilder internally

Improvements

  • Removed version macros (not needed for single-header libraries)
  • Comprehensive unit tests for all new functions (58 tests total)
  • Enhanced documentation with detailed examples

Usage

Just include the single header file:

#define DS_IMPLEMENTATION
#include "dynamic_string.h"

For atomic reference counting (requires C11):

#define DS_ATOMIC_REFCOUNT 1
#define DS_IMPLEMENTATION  
#include "dynamic_string.h"

v0.0.1 - Initial Release

23 Aug 01:10

Choose a tag to compare

Pre-release

Initial release of dynamic_string.h

Features:

  • Reference counted immutable strings
  • Copy-on-write StringBuilder
  • Unicode codepoint iteration
  • Single-file header library
  • Dual licensed: MIT / Unlicense