Releases: Nowazish-Nur-Kayef/NanoDS
NanoDS v1.0.0 - The Production Standard: Enterprise-Grade Security & Advanced Data Structures for C
🚀 NanoDS v1.0.0 - The Production Standard
Release Date: 02 February 2025
Type: Major Release
Status: ✅ Production-Ready
🎉 Major Milestone
NanoDS v1.0.0 marks the transition from experimental library to production-ready standard. This release focuses on enterprise-grade security, advanced data structures, and universal APIs.
Why v1.0.0 Matters
- 🔐 Security Hardened: Anti-DoS protection prevents hash-flooding attacks
- 📦 Feature Complete: 6 data structures with universal iterators
- ⚡ Performance Optimized: Compiler hints for maximum speed
- 🛡️ Memory Safe: Secure flags automatically wipe sensitive data
- ✅ Battle Tested: 36+ CI/CD tests across platforms
- 📚 Well Documented: Complete architecture documentation
🆕 What's New
1. 🔐 Anti-DoS Security (Hash Randomization)
Problem Solved: Hash-flooding attacks can degrade O(1) map operations to O(n) by forcing collisions.
Solution: Randomized hash seeding makes collisions unpredictable.
// Initialize once at program startup
nanods_seed_init(0);
// Every map uses randomized seed
NanoMap map;
nm_init(&map);
printf("Seed: 0x%08X\n", map.seed); // Different every run!Security Impact:
- ✅ Prevents DoS attacks via hash collision
- ✅ Seed changes per program execution
- ✅ Attackers cannot predict bucket distribution
- ✅ Same protection used by Python, Ruby, Java
2. 🛡️ Secure Memory Wiping
Problem Solved: Sensitive data (passwords, keys) may remain in freed memory.
Solution: NANODS_FLAG_SECURE automatically zeros memory before free.
// Passwords will be securely wiped
IntVector passwords;
nv_init_ex_int(&passwords, NANODS_FLAG_SECURE);
// ... store passwords ...
nv_free_int(&passwords); // Automatically calls memset(0)Security Impact:
- ✅ Protects against memory dump attacks
- ✅ No sensitive data in freed memory
- ✅ Zero performance overhead when not used
- ✅ Works with all containers (Vector, Stack, List, List2, Ring, Map)
Use Cases:
- Password storage
- Cryptographic key material
- PII (Personally Identifiable Information)
- Authentication tokens
3. 📦 Doubly Linked Lists (List2)
New Data Structure: Bidirectional traversal with O(1) operations on both ends.
IntList2 list;
nl2_init_int(&list);
// Add to both ends
nl2_push_front_int(&list, 10);
nl2_push_back_int(&list, 20);
// Remove from both ends (O(1)!)
int front, back;
nl2_pop_front_int(&list, &front); // O(1)
nl2_pop_back_int(&list, &back); // O(1) - impossible with singly-linked!
nl2_free_int(&list);Key Features:
- ✅ O(1) pop from tail (vs O(n) for singly-linked)
- ✅ Bidirectional traversal
- ✅ Node insertion/removal with direct node reference
- ✅ Pre-defined types:
IntList2,FloatList2,DoubleList2,CharList2
Performance:
| Operation | Singly-Linked | Doubly-Linked |
|---|---|---|
| push_front | O(1) | O(1) |
| push_back | O(1) | O(1) |
| pop_front | O(1) | O(1) |
| pop_back | O(n) | O(1) ✨ |
4. ⭕ Ring Buffers (Circular Buffer)
New Data Structure: Fixed-size, zero-heap allocation, perfect for embedded systems.
// 64-element ring buffer (stack-allocated!)
IntRing64 ring;
nr_init_int_64(&ring);
// Write data (FIFO)
for (int i = 0; i < 10; i++) {
nr_write_int_64(&ring, i);
}
// Read data
while (!nr_is_empty_int_64(&ring)) {
int val;
nr_read_int_64(&ring, &val);
printf("%d ", val);
}Key Features:
- ✅ Zero heap allocation (entirely stack-based)
- ✅ Fixed size at compile time
- ✅ 1.2 billion ops/sec throughput
- ✅ Circular indexing for wraparound
- ✅ Pre-defined sizes: 16, 32, 64, 128, 256
Perfect For:
- Real-time audio/video buffers
- Embedded systems (no malloc)
- Producer-consumer queues
- Fixed-size history buffers
- IoT sensor data streams
Memory Comparison:
Vector (dynamic): 32 bytes + heap allocation
Ring64 (fixed): 296 bytes, 100% stack
5. 🔄 Universal Iterators
New API: Consistent traversal across all containers.
// Vector iterator
IntVector vec;
nv_init_int(&vec);
// ... add elements ...
NanoIter it = nv_iter_int(&vec);
while (!it.finished) {
int* val = (int*)it.ptr;
printf("%d ", *val);
nv_iter_next_int(&it);
}
// Same pattern for List, List2, Map!Supported Containers:
- ✅ Vector:
nv_iter_TYPE() - ✅ List:
nl_iter_TYPE() - ✅ List2:
nl2_iter_TYPE() - ✅ Map:
nm_iter()
Benefits:
- ✅ Consistent API reduces cognitive load
- ✅ Easy to switch data structures
- ✅ Familiar for-each pattern
- ✅ Type-safe element access
6. ⚡ Compiler Optimization Hints
New Feature: Branch prediction hints for maximum performance.
// Error paths are unlikely
if (NANODS_UNLIKELY(!ptr)) return NANODS_ERR_NULL;
// Success paths are likely
if (NANODS_LIKELY(size < capacity)) {
// Fast path
}Implementation:
#ifdef __GNUC__
#define NANODS_LIKELY(x) __builtin_expect(!!(x), 1)
#define NANODS_UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
#define NANODS_LIKELY(x) (x)
#define NANODS_UNLIKELY(x) (x)
#endifPerformance Impact:
- ✅ 5-10% improvement in real-world code
- ✅ Better CPU branch prediction
- ✅ Reduced pipeline stalls
- ✅ Zero overhead on unsupported compilers
Applied To:
- NULL pointer checks
- Bounds validation
- Memory allocation failures
- Error handling paths
📚 Documentation Enhancements
New: DESIGN.md
Complete architecture documentation covering:
- Memory Layout - Visual diagrams for all structures
- Growth Strategy - Mathematical analysis of 2x exponential growth
- Security Architecture - Anti-DoS and secure wipe design
- Compiler Optimizations - Branch hints and cache-friendly design
- Performance Characteristics - Big-O complexity analysis
- Thread Safety - Guidance for concurrent use
- Custom Allocators - Advanced memory management patterns
- Benchmarking Methodology - How we measure performance
Location: docs/DESIGN.md
Updated: README.md
New sections:
- ✅ Complete Big-O Table - Best/Average/Worst for every operation
- ✅ Security Features - Anti-DoS and secure wipe explained
- ✅ Migration Guide - Zero breaking changes from v0.1.1
- ✅ Real-World Examples - Production-quality use cases
- ✅ Use Case Matrix - Which structure for which problem
Enhanced: CHANGELOG.md
Comprehensive v1.0.0 changelog with:
- Detailed feature descriptions
- API additions (no breaking changes)
- Performance benchmarks
- Security impact analysis
- Migration instructions
🏗️ Build System Improvements
CMake Export Support
New Feature: Downstream projects can use find_package()
# In your CMakeLists.txt
find_package(nanods 1.0.0 REQUIRED)
target_link_libraries(myapp PRIVATE nanods::nanods)Installed Files:
/usr/local/lib/cmake/nanods/
├── nanods-config.cmake
├── nanods-config-version.cmake
└── nanods-targets.cmake
Installation:
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build build
sudo cmake --install buildAutomatic Version Injection
New Feature: Bundler automatically injects version into single-file distribution.
# scripts/bundle.py
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_PATCH = 0Result:
// In nanods_bundled.h
#define NANODS_VERSION_MAJOR 1
#define NANODS_VERSION_MINOR 0
#define NANODS_VERSION_PATCH 0
#define NANODS_VERSION "1.0.0"Benefits:
- ✅ Single source of truth for versioning
- ✅ No manual updates needed
- ✅ Bundled file always correctly versioned
📊 Performance Benchmarks
Maintained Performance
All v0.1.1 operations maintain identical performance:
| Operation | v0.1.1 | v1.0.0 | Change |
|---|---|---|---|
| Vector Push | 340M ops/sec | 340M ops/sec | ✅ Same |
| Stack Push/Pop | 920M ops/sec | 920M ops/sec | ✅ Same |
| List Push | 53M ops/sec | 53M ops/sec | ✅ Same |
| Map Set/Get | 500K ops/sec | 500K ops/sec | ✅ Same |
New Structure Performance
| Operation | Throughput | Latency | Notes |
|---|---|---|---|
| List2 Push | 48M ops/sec | 0.021 µs | O(1) bidirectional |
| List2 Pop Back | 51M ops/sec | 0.020 µs | O(1) vs O(n) singly |
| Ring Write/Read | 1.2B ops/sec | 0.0008 µs | Zero heap! |
Test Environment:
- CPU: Intel i7-10700K @ 3.8GHz
- RAM: 32GB DDR4 @ 3200MHz
- Compiler: GCC 11.2 with -O3 -march=native
- OS: Linux 5.15
🔒 Security Guarantees
Hash Randomization
Threat Model: Attacker sends crafted keys to force O(n) behavior
Protection:
Attacker sends keys → Hash = FNV1a(key) ^ random_seed
↓
Unpredictable bucket distribution
↓
DoS prevented ✓
Entropy Sources:
time()- Current timestamp- Address space layout randomization (ASLR)
- User-provided seed (optional)
Security Level: Same as Python 3.3+, Ruby 1.9+, Java 8+
Secure Memory ...
NanoDS v0.1.1 - Production-Ready Memory-Safe Data Structures for C
🚀 NanoDS v0.1.1 - The "Ecosystem" Release
Release Date: 2025-01-16
Type: Minor Release (Backward Compatible)
📋 TL;DR
NanoDS v0.1.1 brings modular architecture, functional programming features (map/filter), comprehensive benchmarks, and seamless build system integration (CMake, pkg-config) while maintaining 100% backward compatibility with v0.1.0.
✨ What's New:
- 🎨 Split-header architecture for easier maintenance
- 🔄 Functional operations:
nv_map()andnv_filter() - 📊 Empirical benchmark suite with CSV export
- 🏗️ CMake and pkg-config integration
- 🎮 Real-world examples (word counter, command history)
- 📦 Single-file bundler script
🔧 No Breaking Changes - Drop-in replacement for v0.1.0
🎯 Highlights
1️⃣ Modular Architecture
The codebase has been reorganized into logical modules while maintaining the single-header distribution model:
NanoDS/
├── nanods.h # Main header (unchanged API)
└── src/
├── core.h # Allocator & utilities
├── vector_impl.h # Vector implementation
├── stack_impl.h # Stack implementation
├── list_impl.h # List implementation
└── map_impl.h # Map implementation
Benefits:
- ✅ Easier navigation and maintenance
- ✅ Better IDE support with code navigation
- ✅ Clear separation of concerns
- ✅ Still works as single-header (via bundler)
Migration: None required - #include "nanods.h" works exactly as before
2️⃣ Functional Programming Features
Bring modern functional patterns to C with map and filter operations:
Map: Transform Every Element
int double_value(int x) {
return x * 2;
}
IntVector numbers;
nv_init_int(&numbers);
nv_push_int(&numbers, 1);
nv_push_int(&numbers, 2);
nv_push_int(&numbers, 3);
IntVector doubled;
nv_map_int(&numbers, &doubled, double_value);
// Result: [2, 4, 6]Filter: Select Elements by Predicate
int is_even(int x) {
return x % 2 == 0;
}
IntVector filtered;
nv_filter_int(&numbers, &filtered, is_even);
// Result: [2]Available for: All vector types (int, float, double, char, custom)
Performance: O(n) with minimal overhead
3️⃣ Comprehensive Benchmark Suite
New benchmarks/ directory with empirical performance data:
Included Benchmarks
| Benchmark | Measures | Output |
|---|---|---|
bench_vector.c |
Vector push, get, reserve | Throughput, latency |
bench_map.c |
Map operations (1K-1M entries) | Ops/sec, load factor |
bench_comparison.c |
NanoDS vs naive implementation | Overhead comparison |
Run Benchmarks
make benchmarks
make run-benchmarksSample Output:
==============================================
NanoDS Vector Benchmark
==============================================
Sequential Push (1000000 ops):
Time: 2.94 ms
Throughput: 340136054 ops/sec
Latency: 0.003 µs/op
Random Access Get (1000000 ops):
Time: 1.08 ms
Throughput: 925925926 ops/sec
Latency: 0.001 µs/op
CSV Export: Results can be exported for tracking regression
4️⃣ Build System Integration
CMake Support
Add NanoDS to your CMake project:
# Option 1: Add as subdirectory
add_subdirectory(NanoDS)
target_link_libraries(myapp PRIVATE nanods)
# Option 2: Find installed package
find_package(nanods REQUIRED)
target_link_libraries(myapp PRIVATE nanods::nanods)Features:
- ✅ Header-only interface library
- ✅ Configurable options (tests, benchmarks, examples)
- ✅ Install targets for system-wide installation
- ✅ Export targets for downstream projects
Install:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
sudo cmake --install buildpkg-config Support
Linux-style package configuration:
# Check installation
pkg-config --modversion nanods
# Get compile flags
gcc $(pkg-config --cflags nanods) myapp.c -o myapp
# Integration with Autotools
PKG_CHECK_MODULES([NANODS], [nanods >= 0.1.1])Installed files:
/usr/local/include/nanods.h/usr/local/include/nanods/src/*.h/usr/local/lib/pkgconfig/nanods.pc
5️⃣ Real-World Examples
Two production-quality examples demonstrating practical usage:
Word Frequency Counter
File: examples/word_frequency.c
Demonstrates:
- Hash map usage for counting
- String manipulation and parsing
- Iterator patterns
- Memory management
Output:
Word Frequencies:
─────────────────────────────────
the : 3
quick : 1
fox : 2
─────────────────────────────────
Total unique words: 8
🏆 Most common word: 'the' (3 times)
Command History Manager
File: examples/command_history.c
Demonstrates:
- Vector usage for sequential data
- Custom struct storage
- Search and filtering
- Practical CLI patterns
Output:
Command History:
─────────────────────────────────────────────
1 [T=1000] git status
2 [T=1005] git add .
3 [T=1010] git commit -m 'feat'
─────────────────────────────────────────────
Searching for: 'git'
1 [T=1000] git status
2 [T=1005] git add .
3 [T=1010] git commit -m 'feat'
6️⃣ Single-File Bundler
File: scripts/bundle.py
Merge split headers back into a single file for distribution:
python3 scripts/bundle.py
# Creates: nanods_bundled.hUse Cases:
- 📦 Single-file distribution
- 🚀 Quick integration (just one file)
- 📤 Easy sharing
Maintains: All functionality, just different packaging
📦 What's Included
New Files
NanoDS/
├── src/
│ ├── core.h # Core utilities
│ ├── vector_impl.h # Vector implementation
│ ├── stack_impl.h # Stack implementation
│ ├── list_impl.h # List implementation
│ └── map_impl.h # Map implementation
├── benchmarks/
│ ├── bench_vector.c # Vector benchmarks
│ ├── bench_map.c # Map benchmarks
│ ├── bench_comparison.c # Comparison benchmarks
│ └── run_benchmarks.sh # Benchmark runner
├── examples/
│ ├── word_frequency.c # Word counter example
│ └── command_history.c # Command history example
├── scripts/
│ └── bundle.py # Single-file bundler
├── CMakeLists.txt # CMake configuration
└── nanods.pc.in # pkg-config template
Updated Files
- nanods.h - Updated version to 0.1.1, includes modular headers
- test.c - Added functional operations tests
- Makefile - New targets:
examples,benchmarks,bundle,install - README.md - Complete rewrite with API gallery and real examples
- CHANGELOG.md - Detailed v0.1.1 changes
- .github/workflows/ci.yml - Enhanced CI with CMake and examples
🔄 API Changes
New Functions (v0.1.1)
Vector Map
int nv_map_TYPE(const NanoVector_TYPE* vec,
NanoVector_TYPE* out,
TYPE (*func)(TYPE));Description: Apply function to every element
Returns: NANODS_OK or error code
Example: nv_map_int(&vec, &result, double_value)
Vector Filter
int nv_filter_TYPE(const NanoVector_TYPE* vec,
NanoVector_TYPE* out,
int (*predicate)(TYPE));Description: Create new vector based on predicate
Returns: NANODS_OK or error code
Example: nv_filter_int(&vec, &result, is_even)
No Breaking Changes
All v0.1.0 functions remain unchanged:
| Category | Functions | Status |
|---|---|---|
| Vector | nv_init, nv_push, nv_get, nv_set, nv_pop, nv_free |
✅ Unchanged |
| Stack | ns_init, ns_push, ns_pop, ns_peek, ns_free |
✅ Unchanged |
| List | nl_init, nl_push_front, nl_push_back, nl_pop_front, nl_free |
✅ Unchanged |
| Map | nm_init, nm_set, nm_get, nm_has, nm_remove, nm_free |
✅ Unchanged |
| Allocator | nanods_set_allocator, nanods_get_allocator |
✅ Unchanged |
✅ 100% Backward Compatible
📊 Performance
Unchanged Performance Characteristics
All operations maintain the same performance as v0.1.0:
| Operation | v0.1.0 | v0.1.1 | Status |
|---|---|---|---|
| Vector Push | 340M ops/sec | 340M ops/sec | ✅ Same |
| Stack Push/Pop | 920M ops/sec | 920M ops/sec | ✅ Same |
| List Push | 53M ops/sec | 53M ops/sec | ✅ Same |
| Map Set/Get | 500K ops/sec | 500K ops/sec | ✅ Same |
New Operations Performance
| Operation | Throughput | Complexity |
|---|---|---|
nv_map() |
~300M ops/sec | O(n) |
nv_filter() |
~250M ops/sec | O(n) |
Overhead: Minimal function call overhead only
🛡️ Security & Safety
No Security Changes
All v0.1.0 safety features remain:
- ✅ Integer overflow protection
- ✅ Bounds checking
- ✅ NULL pointer validation
- ✅ Memory sanitization
- ✅ Valgrind verified (zero leaks)
Additional Safety
- ✅ New functions follow same safety patterns
- ✅ Functional operations validate all pointers
- ✅ CMake builds include safety checks
- ✅ Extended CI/CD testing
🧪 Testing
Enhanced CI/CD
New CI jobs added:
| Job | Description | Status |
|---|---|---|
| Build Examples | Compile and run examples | ✅ Passing |
| Build Benchmarks | Compile and run benchmarks | ✅ Passing |
| CMake Build | Test CMake integration | ✅ Passing |
| Bundle Script | Test single-file generation | ✅ Passing |
Total CI jobs:...
NanoDS v0.1.0 - Production-Ready Memory-Safe Data Structures for C
🚀 NanoDS v0.1.0 - Production Release
I'm excited to announce the first production release of NanoDS, a memory-safe, single-header C library for generic data structures with zero dependencies.
✨ What is NanoDS?
NanoDS brings modern, type-safe data structures to C without the complexity of C++. Perfect for embedded systems, game engines, system programming, and any project where memory safety and simplicity matter.
📦 What's Included
Data Structures
- ✅ NanoVector - Generic dynamic arrays with automatic growth
- ✅ NanoStack - LIFO stack (composition over vector)
- ✅ NanoList - Singly linked list with O(1) operations
- ✅ NanoMap - String-keyed hash map with FNV-1a hashing
Safety Features
- 🛡️ Hybrid Safety System - Assert-based debugging + optional hard runtime checks
- 🔒 Integer Overflow Protection - All allocations checked against
SIZE_MAX - 🔐 Memory Safety - Bounds checking, NULL validation, secure free
⚠️ Error Codes - Comprehensive error handling (NANODS_ERR_NOMEM,NANODS_ERR_BOUNDS, etc.)
Production Features
- 🔧 Custom Allocator Support - Full allocator interface for embedded systems
- 📦 Single Header - Just drop
nanods.hinto your project - 🚀 Zero Dependencies - Only requires standard C library
- 🌍 Cross-Platform - Linux, macOS, Windows
- ✅ CI/CD Tested - Automated testing on multiple platforms and compilers
- 🧪 Valgrind Verified - Zero memory leaks
🚀 Quick Start
Download
Option 1: Direct Download
wget https://raw.githubusercontent.com/Nowazish-Nur-Kayef/NanoDS/v0.1.0/nanods.hOption 2: Clone Repository
git clone --branch v0.1.0 https://github.com/Nowazish-Nur-Kayef/NanoDS.gitBasic Usage
#define NANODS_IMPLEMENTATION
#include "nanods.h"
#include <stdio.h>
int main(void) {
// Create a vector
IntVector vec;
nv_init_int(&vec);
// Add elements
nv_push_int(&vec, 42);
nv_push_int(&vec, 100);
// Access elements
int value;
nv_get_int(&vec, 0, &value);
printf("Value: %d\n", value);
// Clean up
nv_free_int(&vec);
return 0;
}Compile:
gcc -std=c11 -Wall -Wextra your_code. c -o your_program📊 Performance
Benchmarked on Linux with GCC -O3:
| Operation | Performance | Complexity |
|---|---|---|
| Vector Push | ~340M ops/sec | O(1) amortized |
| Stack Push/Pop | ~920M ops/sec | O(1) |
| List Push | ~53M ops/sec | O(1) |
| Map Set/Get | ~500K ops/sec | O(1) average |
🛡️ Safety Modes
Debug Mode (Default)
#define NANODS_IMPLEMENTATION
#include "nanods.h"
// Uses assert() for developmentHard Safety Mode (Production)
#define NANODS_HARD_SAFETY
#define NANODS_IMPLEMENTATION
#include "nanods.h"
// Runtime error checking without asserts🔧 Custom Allocators
For embedded systems or custom memory management:
NanoAllocator custom = {
.malloc_fn = my_malloc,
.realloc_fn = my_realloc,
.free_fn = my_free
};
nanods_set_allocator(&custom);
// All operations now use custom allocator
IntVector vec;
nv_init_int(&vec);📚 Documentation
- 📖 README.md - Complete API reference and examples
- 📝 CHANGELOG.md - Detailed version history
- 💻 Examples - Real-world usage examples
🧪 Testing
This release includes:
- ✅ Comprehensive test suite covering all data structures
- ✅ Memory leak verification with Valgrind (zero leaks)
- ✅ Multi-platform CI/CD (Ubuntu, macOS, Windows)
- ✅ Multiple compiler testing (GCC 11-12, Clang 14-15)
- ✅ Performance benchmarking
🎯 Use Cases
Perfect for:
- 🎮 Game Engines - Entity systems, collections
- 🔧 Embedded Systems - Memory-constrained environments
- 🛠️ System Programming - Safe low-level data management
- 📊 Data Processing - Dynamic collections without C++ overhead
- 🔐 Security Tools - Secure memory handling
📥 Downloads
| File | Description | Size |
|---|---|---|
| Source code (zip) | Full source with tests | ~50 KB |
| Source code (tar.gz) | Full source with tests | ~45 KB |
🔄 What's New in v0.1.0
Added
- 🆕 Initial production release
- 🆕 NanoVector, NanoStack, NanoList, NanoMap
- 🆕 Hybrid safety system (assert + hard safety)
- 🆕 Custom allocator interface
- 🆕 Comprehensive error codes
- 🆕 Cross-platform CI/CD pipeline
- 🆕 Doxygen-style API documentation
- 🆕 Performance benchmark suite
Security
- 🔒 Integer overflow protection on all allocations
- 🔒 Bounds checking on all array access
- 🔒 NULL pointer validation on all APIs
- 🔒 Safe reallocation to prevent memory leaks
- 🔒 FNV-1a hashing resistant to DoS attacks
🧰 Technical Details
- Language: C11
- Compiler Support: GCC 4.9+, Clang 3.4+, MSVC 2015+
- Platforms: Linux, macOS, Windows, embedded systems
- Dependencies: None (only standard C library)
- License: MIT / Public Domain
🤝 Contributing
Contributions are welcome!
- 🐛 Report bugs: Open an issue
- 💡 Request features: Start a discussion
- ⭐ Star the repo: Help others discover NanoDS
🙏 Acknowledgments
- Inspired by stb libraries by Sean Barrett
- FNV-1a hash algorithm by Fowler, Noll, and Vo
- Thanks to the C community for feedback and support
📞 Support
- 📧 Issues: GitHub Issues
- 💬 Discussions: GitHub Discussions
- 📖 Documentation: README.md
🚀 Future Roadmap
Planned for future releases:
- Doubly linked lists
- Queue/Deque implementations
- Binary search trees
- More performance optimizations
- Additional examples and tutorials
⭐ Show Your Support
If you find NanoDS useful, please consider:
- ⭐ Starring the repository
- 🐦 Sharing with the C community
- 💬 Providing feedback
Made with ❤️ for the C community
Production-ready • Memory-safe • Zero dependencies
Full Changelog: https://github.com/Nowazish-Nur-Kayef/NanoDS/blob/v0.1.0/CHANGELOG.md
Author: Nowazish-Nur-Kayef
License: MIT
v0.0.1
🎉 NanoDS v0.0.1 - Initial Release
I'm excited to announce the first release of NanoDS, a memory-safe, single-header C library for generic data structures with zero dependencies.
⚠️ Note: This is an initial release (v0.0.1). While thoroughly tested, please report any issues you encounter!
✨ What is NanoDS?
NanoDS brings modern, type-safe data structures to C without complexity. Perfect for embedded systems, game engines, or any project where memory safety and simplicity matter.
Key Features
- 📦 Single-Header Library - Drop
nanods.hinto your project and go - 🔒 Type-Safe Generics - Compile-time safety using C macros
- 🛡️ Security First - Integer overflow protection, bounds checking, safe realloc
- 🗺️ Fast Hash Maps - FNV-1a algorithm with collision resistance
- ✅ Zero Memory Leaks - Valgrind verified
- 🚀 Zero Dependencies - Only requires standard C library
- 🌍 Cross-Platform - Linux, macOS, Windows
📦 What's Included
Data Structures
- NanoVector - Generic dynamic arrays for any type (
int,float, customstruct) - NanoMap - Fast string-keyed hash maps with O(1) average lookup
Security Features
- ✅ Integer overflow protection on all allocations
- ✅ Safe reallocation wrappers to prevent memory leaks
- ✅ Bounds checking with assertions
- ✅ Optional secure free with memory zeroing
- ✅ FNV-1a hashing for DoS resistance
🚀 Quick Start
Installation
Download directly:
wget https://raw.githubusercontent.com/Nowazish-Nur-Kayef/NanoDS/v0.0.1/nanods. hOr clone the repository:
git clone --branch v0.0.1 https://github.com/Nowazish-Nur-Kayef/NanoDS.git
cd NanoDSBasic Usage
#define NANODS_IMPLEMENTATION
#include "nanods.h"
#include <stdio.h>
int main(void) {
// Create a type-safe integer vector
IntVector vec;
nv_init_int(&vec);
// Add elements
nv_push_int(&vec, 42);
nv_push_int(&vec, 100);
nv_push_int(&vec, 256);
// Access elements
printf("First: %d\n", nv_get_int(&vec, 0));
printf("Size: %zu\n", nv_size_int(&vec));
// Clean up
nv_free_int(&vec);
return 0;
}Hash Map Example
NanoMap config;
nm_init(&config);
int port = 8080;
nm_set(&config, "port", &port);
int* result = (int*)nm_get(&config, "port");
printf("Port: %d\n", *result);
nm_free(&config);Custom Types
typedef struct { int x, y; } Point;
NANODS_DEFINE_VECTOR(Point)
NanoVector_Point points;
nv_init_Point(&points);
nv_push_Point(&points, (Point){10, 20});
nv_free_Point(&points);🔨 Building & Testing
Using Make
# Build test suite
make
# Run tests
make run
# Check for memory leaks
make valgrind
# Clean
make cleanManual Compilation
gcc -std=c11 -Wall -Wextra test. c -o nanods_test
./nanods_test📊 What's in v0.0.1
Features
- ✅ Generic type-safe vectors (NanoVector)
- ✅ String-keyed hash maps (NanoMap)
- ✅ Integer overflow protection
- ✅ Safe memory allocation wrappers
- ✅ Secure free with memory zeroing
- ✅ Comprehensive test suite
- ✅ Cross-platform Makefile
- ✅ Full API documentation
Security
- ✅ All size calculations protected against overflow
- ✅ Bounds checking on all array operations
- ✅ Memory leak prevention in realloc failures
- ✅ FNV-1a hashing for collision resistance
Tested On
- ✅ GCC 11.4+ (Linux)
- ✅ Clang 14.0+ (macOS)
- ✅ MSVC 2019+ (Windows)
- ✅ Valgrind 3.19+ (Zero leaks confirmed)
📥 Downloads
| File | Description |
|---|---|
nanods.h |
Main library (header-only) |
| Source code (zip) | Full source with examples |
| Source code (tar.gz) | Full source with examples |
📚 Documentation
Full API documentation is available in the README.
Quick Reference
Vectors:
nv_init_TYPE(&vec)- Initializenv_push_TYPE(&vec, value)- Add elementnv_get_TYPE(&vec, index)- Get elementnv_size_TYPE(&vec)- Get sizenv_free_TYPE(&vec)- Free memory
Maps:
nm_init(&map)- Initializenm_set(&map, key, value)- Set key-valuenm_get(&map, key)- Get valuenm_has(&map, key)- Check existencenm_free(&map)- Free memory
🎯 Use Cases
Perfect for:
- 🎮 Game engines (entity lists, configuration)
- 🔧 Embedded systems (memory-constrained environments)
- 🛠️ System programming (safe data management)
- 📊 Data processing (dynamic collections)
- 🔐 Security tools (with secure free)
🐛 Known Issues
None at this time. Please report any issues you find!
🚧 Roadmap
Future features under consideration:
- 🔗 Linked Lists
- 📚 Queues/Deques
- 🌳 Binary Trees
- 📈 Performance benchmarks
- 🎨 More examples
Want to see a specific feature? Open an issue and let me know!
🤝 Contributing
This is the first release, and your feedback is invaluable!
- 🐛 Found a bug? Open an issue
- 💡 Have an idea? Start a discussion
- ⭐ Like it? Star the repo to help others discover it!
📝 License
This project is licensed under the MIT License. See LICENSE for details.
🙏 Acknowledgments
- Inspired by stb libraries by Sean Barrett
- FNV-1a hash algorithm by Fowler, Noll, and Vo
📞 Feedback Welcome!
If you find NanoDS useful, please consider:
- ⭐ Starring the repository
- 🐦 Sharing with the C community
- 💬 Providing feedback on what works and what doesn't
Author: Nowazish-Nur-Kayef
Full Changelog: https://github.com/Nowazish-Nur-Kayef/NanoDS/commits/v0.0.1
Made with ❤️ for the C community
Your feedback will shape the future of NanoDS!