{"id":19152589,"url":"https://github.com/bamless/extlib","last_synced_at":"2026-04-11T14:16:13.076Z","repository":{"id":114070346,"uuid":"338617036","full_name":"bamless/extlib","owner":"bamless","description":"c extended library","archived":false,"fork":false,"pushed_at":"2026-04-06T08:55:32.000Z","size":476,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-06T10:29:24.247Z","etag":null,"topics":["array","c","c11","c99","dynamic","dynamic-array","dynamic-arrays","hashmap","hashmap-c","hashtable","single-header","string","string-buffer","string-builder","vector"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bamless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-13T16:29:06.000Z","updated_at":"2026-04-06T08:54:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"f36ce511-b6da-4baf-991a-51e82bce5bfb","html_url":"https://github.com/bamless/extlib","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/bamless/extlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamless%2Fextlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamless%2Fextlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamless%2Fextlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamless%2Fextlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamless","download_url":"https://codeload.github.com/bamless/extlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamless%2Fextlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31683485,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T13:07:20.380Z","status":"ssl_error","status_checked_at":"2026-04-11T13:06:47.903Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","c","c11","c99","dynamic","dynamic-array","dynamic-arrays","hashmap","hashmap-c","hashtable","single-header","string","string-buffer","string-builder","vector"],"created_at":"2024-11-09T08:18:26.637Z","updated_at":"2026-04-11T14:16:13.069Z","avatar_url":"https://github.com/bamless.png","language":"C","readme":"# extlib: c extended library\n\n[![Build](https://github.com/bamless/extlib/actions/workflows/build.yml/badge.svg)](https://github.com/bamless/extlib/actions/workflows/build.yml)\n\nextlib is a header-only library that implements common data structures and algorithms that are not\nprovided by the c standard library.\n\nFeatures:\n- Context abstraction to easily modify the application's allocation and logging behaviour\n- Custom Allocators that easily integrate with the context and datastructures\n- Generic, type-safe dynamic arrays and hash maps\n- StringBuffer for easily working with dynamic buffers of bytes\n- StringSlice for easy manipulation of immutable 'views' over byte buffers\n- Cross-platform IO functions for working with processes, files and more generally\n  interacting with the operating system\n- Configurable logging\n- Misc utility macros\n- No-std and wasm support\n\n## Quickstart\n\n To use the library do this in *exactly one* c file:\n ```c\n #define EXTLIB_IMPL\n // Optional configuration options\n #include \"extlib.h\"\n ```\n\n\u003e NOTE: The library by default exports all symbols without any prefix. If you find any conflicts\n\u003e when using in your project, you can define `EXTLIB_NO_SHORTHANDS` before including any of the\n\u003e library headers to disable names without prefixes.\n\n Configuration options:\n```c\n#define EXTLIB_NO_SHORTHANDS  // Disable shorthands names, only prefixed one will be defined\n#define EXTLIB_NO_STD         // Do not use libc functions\n#define EXTLIB_WASM           // Enable when compiling for wasm target. Implies EXTLIB_NO_STD\n#define EXTLIB_THREADSAFE     // Thread safe Context\n#define EXTLIB_SHARED_EXPORT  // Mark all public API symbols for shared library use (see below)\n#define NDEBUG                // Strips runtime assertions and replaces unreachables with compiler\n                              // intrinsics\n```\n\n### Building as a shared library\n\nDefine `EXTLIB_SHARED_EXPORT` to enable the `EXT_API` visibility attribute on all public symbols,\nmaking it possible to compile extlib as a DLL or shared object.\n\nThe macro behaves differently depending on whether the translation unit is building the\nimplementation or consuming it:\n\n- **Implementation TU** (`EXTLIB_IMPL` defined): symbols are *exported*.\n- **Consumer TUs** (`EXTLIB_IMPL` not defined): symbols are *imported*.\n\nOn **Windows** this maps to `__declspec(dllexport)` / `__declspec(dllimport)`.\nOn **GCC / Clang** both use `__attribute__((visibility(\"default\")))`.\nOn unrecognized compilers/platforms the attribute expands to nothing.\n\nOn GCC / Clang it is strongly recommended to compile the shared library with\n`-fvisibility=hidden`. Without it all symbols are public by default, defeating the purpose of\n`EXT_API` and leaking internal symbols into the DSO's export table. `EXT_API` then selectively\nrestores visibility only for the symbols that are meant to be public.\n\nA typical CMake setup looks like:\n\n```cmake\n# Shared library target — EXTLIB_IMPL builds the implementation and exports symbols.\n# -fvisibility=hidden ensures only EXT_API-marked symbols are exported on GCC/Clang.\nadd_library(extlib SHARED extlib_impl.c)\ntarget_compile_definitions(extlib PRIVATE EXTLIB_IMPL EXTLIB_SHARED_EXPORT)\ntarget_compile_options(extlib PRIVATE $\u003c$\u003cC_COMPILER_ID:GNU,Clang,AppleClang\u003e:-fvisibility=hidden\u003e)\n\n# Consumer target — only EXTLIB_SHARED_EXPORT is defined so symbols are imported\ntarget_compile_definitions(my_app PRIVATE EXTLIB_SHARED_EXPORT)\ntarget_link_libraries(my_app extlib)\n```\n\nWhere `extlib_impl.c` contains exactly:\n```c\n#define EXTLIB_IMPL\n#include \"extlib.h\"\n```\n\n## Examples\n\nYou can find a bunch of examples showcasing library features in `examples/`\n\n### Minimal example\n\n```c\n#include \u003cstddef.h\u003e\n#include \u003cstdio.h\u003e\n#define EXTLIB_IMPL\n#include \"extlib.h\"\n\ntypedef struct {\n    StringSlice key;\n    int value;\n} WordFreq;\n\n// Could also create this typedef with `HashMap` utility macro:\n//     typedef HashMap(StringSlice, int) WordMap;\ntypedef struct {\n    WordFreq* entries;\n    size_t* hashes;\n    size_t size, capacity;\n    Allocator* allocator;\n} WordMap;\n\n// Could also create this typedef with `Array` utility macro:\n//     typedef Array(StringSlice) Words;\ntypedef struct {\n    StringSlice* items;\n    size_t size, capacity;\n    Allocator* allocator;\n} Words;\n\nint main(int argc, char** argv) {\n    // Push context with temp allocator so that we don't need to free\n    Context ctx = *ext_context;\n    ctx.alloc = \u0026temp_allocator.base;\n    push_context(\u0026ctx);\n\n    Words words = {0};\n    // Could also specify allocators on a per-datastructure level\n    // words.allocator = \u0026default_allocator.base\n    \n    int i;\n    for(i = 1; i \u003c argc; i++) {\n        StringSlice line = ss_from_cstr(argv[i]);\n        while(line.size) {\n            StringSlice word = ss_split_once_ws(\u0026line);\n            array_push(\u0026words, word);\n        }\n    }\n    ext_log(INFO, \"Processed %d lines\", i-1);\n\n    printf(\"Words:\\n\");\n    array_foreach(StringSlice, it, \u0026words) {\n        printf(\"  \" SS_Fmt \"\\n\", SS_Arg(*it));\n    }\n\n    WordMap word_freqs = {0};\n    array_foreach(StringSlice, it, \u0026words) {\n        WordFreq* e = hmap_get_default_ss(\u0026word_freqs, *it, 0);\n        e-\u003evalue++;\n    }\n\n    printf(\"Frequency:\\n\");\n    hmap_foreach(WordFreq, it, \u0026word_freqs) {\n        printf(\"  \" SS_Fmt \": %d\\n\", SS_Arg(it-\u003ekey), it-\u003evalue);\n    }\n\n    pop_context();\n}\n```\n\n## Tests\nYou can find tests in `test/test.c`. To run them:\n```sh\nmake test\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamless%2Fextlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamless%2Fextlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamless%2Fextlib/lists"}