Skip to content

acoto87/shl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Single Header Libraries

These are single header libraries that I use in my code, much in the style of Sean Barret stb libraries.

  • list.h: A generic list implementation (see list.md).
  • stack.h: A generic stack implementation (see stack.md).
  • queue.h: A generic queue implementation (see queue.md).
  • binary_heap.h: A generic binary heap implementation (see binary_heap.md)
  • map.h: A generic hash-table implementation (see map.md).
  • set.h: A generic hash-set implementation (see set.md)
  • array.h: A generic helper to work with multi-dimentional arrays.
  • wstr.h: String views and heap strings (see wstr.md).
  • wave_writer.h: Contains functionalities to write .wav files (see wave_writer.md).
  • memory_buffer.h: An in-memory buffer implementation with random access (see memory_buffer.md).
  • flic.h: Contains functionalities to read FLIC files (see flic.md). It's a C port of the C++ implementation by David Capello's Aseprite FLIC Library: https://github.com/aseprite/flic
  • memzone.h: A simple memory allocator. (see memzone.md)
  • memzone_audit.h: Companion header for memzone.h that records every allocator mutation to a structured log file. (see memzone_audit.md)

See the tests/*_tests.c files to see how to use them.

These are work in progress, and I'm using it in my games, so use at your own risk.

Any tips/suggestions are welcome.

Building and running tests

The test suite is built with nob and uses the Unity C test framework. Tests live in tests/ and cover every public API of each header.

cc -std=c99 -Wall -Wextra nob.c -o nob

# Run all tests
./nob test
./nob test all

# Run a single test suite
./nob test wstr_test

# Run under AddressSanitizer
./nob asan
./nob asan array_test

# Run under Valgrind (Linux only)
./nob valgrind

Benchmarks

Microbenchmarks live in benchmarks/ and use ubench.h. Each suite covers all major API operations in isolation, integrated scenarios, and — where applicable — direct comparisons against the stdlib equivalents (malloc / realloc / free).

Suite Source What it covers
list_bench benchmarks/list_bench.c All list.h operations: add, insert, remove, search, sort
memzone_bench benchmarks/memzone_bench.c All memzone.h operations vs malloc / realloc / free
# Build and run all benchmarks
./nob bench

# Build and run a single benchmark suite
./nob bench list_bench
./nob bench memzone_bench

Note on batched benchmarks: O(1) operations (e.g. a single alloc+free or a direct array access) are too short to measure individually on Windows without hitting timer-resolution noise. Those benchmarks perform N = 128 operations per timed sample and report the aggregate mean; divide by 128 for the per-operation cost.

About

Single header libraries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors