ccontainers is a modular and lightweight C library designed to offer essential data structures and utilities tailored for low level programming, and performance-critical applications. It provides a clean, thoroughly-tested foundation for building efficient, safe, and portable C software.
At its core lies a dynamic array module inspired by std::vector (C++), extended with optional iterators, comparators, and utility functions to simplify common data manipulation tasks while ensuring correctness and low overhead.
- Automatic growth and optional shrinking
- Internal memory reuse and compaction support
- Manual or automated value removal via sentinel-based deletion
- Abstracts traversal logic and promotes separation of concerns
- Custom iterators for range-based and condition-based operations
- Built-in comparators (ascending, descending, modulus, etc.)
- Custom comparator support for sorting and searching complex types
- Linear/binary search, conditional setting, and fill/set ranges
remove_valuewith compaction heuristics (25% threshold)
- Unit tests (function-level validation)
- Stress tests (large-scale and edge-case validation)
- Performance benchmarks for profiling and regression tracking
- Clear separation of concerns (e.g., search, comparators, iterators)
- Easy to extend with additional data types and algorithms
- Minimal dependencies; written in portable C14
- All exposed functions validate pointer inputs (e.g.,
struct Array*) - Functions are fail-safe and do not invoke undefined behavior on
NULL
- Internally audited using Valgrind, AddressSanitizer, and manual inspection
- No memory leaks, double frees, or invalid accesses under tested conditions
- Upcoming optional locking support for concurrent usage patterns
Planned enhancements include:
- NULL Safety (implemented in core modules)
- Thread Safety (mutex-guarded array operations)
- Additional Containers
- Singly/doubly linked lists
- Binary trees, graphs (adjacency list/set representations)
- Add-ons and Utilities
- Queues, stacks, and matrix manipulation functions
- Simple hash tables and lightweight encryption
- Compiler Toolchains: GCC, Clang (C14 mode)
- Build System: CMake (for cross-platform management)
- Debugging/Instrumentation:
- Valgrind
- AddressSanitizer (
-fsanitize=address) - LeakSanitizer, UB Sanitizer
- Testing Framework: Custom in-library test harness
- Performance Profiling: gprof, perf, and custom timers
Clone the repository:
git clone https://github.com/042803/ccontainers