P-p-H-d/mlib logo

P-p-H-d/mlib

Free

M*LIB is a library of generic and type safe containers / data structures in pure C language (C99 / C11) for a wide collection of container (comparable to the C++ STL).

FreeFree tier
Type
Open Source

About P-p-H-d/mlib

M*LIB is a library of generic and type-safe containers and data structures written in pure C (C99/C11). It provides a wide collection of containers comparable to the C++ Standard Template Library (STL), including arrays, lists, dictionaries, sets, trees, priority queues, strings, tuples, variants, bitsets, and more. The library emphasizes type safety and genericity through macros, supports lock-free data structures, serialization in JSON and binary formats, and includes algorithms for containers. It is released under the BSD-2-Clause license and has garnered over 1,100 stars on GitHub.

Key Features

Generic and type-safe containers using C preprocessor macros
Wide collection of data structures: arrays, lists, dictionaries, sets, trees, priority queues, strings, tuples, variants, bitsets, and more
Lock-free data structures for concurrent access
Serialization support for JSON and binary formats
Algorithms for containers (e.g., sort, search)
Header-only library (single .h files per container)
Compatible with C99 and C11 standards
BSD-2-Clause open-source license

Pros & Cons

Pros
  • Pure C implementation ensures maximum portability
  • Type safety without sacrificing performance
  • Comprehensive set of containers comparable to C++ STL
  • Lock-free variants enable thread-safe operations
  • Lightweight and header-only, easy to integrate
Cons
  • Requires C99/C11 compatible compiler
  • Macro-based genericity may have a learning curve for newcomers
  • No built-in memory management beyond standard C

Best For

Embedded systems and firmware developmentHigh-performance computing and systems programmingReplacing C++ STL in C projectsGeneral-purpose C application development requiring efficient data structuresBuilding parsers, serializers, and data processing tools