{"id":19922444,"url":"https://github.com/gremble0/nonstdlib","last_synced_at":"2026-02-17T19:02:00.340Z","repository":{"id":211498318,"uuid":"729131680","full_name":"gremble0/nonstdlib","owner":"gremble0","description":"Some usefil utilities for C not provided by the standard library","archived":false,"fork":false,"pushed_at":"2024-08-21T16:40:25.000Z","size":204,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-03T07:37:21.142Z","etag":null,"topics":["algorithms","c","data-structures","library"],"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/gremble0.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}},"created_at":"2023-12-08T13:42:55.000Z","updated_at":"2024-08-21T16:40:29.000Z","dependencies_parsed_at":"2024-01-23T15:27:32.903Z","dependency_job_id":"f16f6230-27e9-4a4b-ab67-407dc9733b63","html_url":"https://github.com/gremble0/nonstdlib","commit_stats":null,"previous_names":["gremble0/nonstdlib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gremble0/nonstdlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gremble0%2Fnonstdlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gremble0%2Fnonstdlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gremble0%2Fnonstdlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gremble0%2Fnonstdlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gremble0","download_url":"https://codeload.github.com/gremble0/nonstdlib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gremble0%2Fnonstdlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278219765,"owners_count":25950349,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-03T02:00:06.070Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["algorithms","c","data-structures","library"],"created_at":"2024-11-12T22:11:01.227Z","updated_at":"2025-10-03T19:51:08.822Z","avatar_url":"https://github.com/gremble0.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nonstdlib\nThis project consists of several modules containing various useful utilities for C such as stacks, hashtables, a nicer version of strings, lists/dynamic arrays and arrays.\n\n## Note on portability\nBecause this project is mostly for fun I have not put any significant effort into maintaining portability to other platforms or compilers. Even though there shouldn't be anything major that is platform/compiler specific, the only way i can guarantee the library to work is to run it on linux with the clang compiler.\n\n## Usage\n**If you want to use this library I would not recommend regularly updating it as I regularly push breaking changes**. To use the library copy it into your project however you want (as a git submodule or cloning directly). Then go into nonstdlib/src and run make:\n```sh\ngit clone git@github.com:gremble0/nonstdlib.git\ncd nonstdlib/src\nmake # or `make debug` if you want to keep debug symbols\n```\nNow the static library `libnonstdlib.a` will be generated inside nonstdlib/src. You can link with the static library and include the headers in your project. All the modules in nonstdlib are prefixed with `n`, see [Modules](#modules) for a full list of modules in the library.\n\n## Example\nConsider this simple file structure:\n```\n.\n├─nonstdlib/\n│ ├─include/\n│ │ └─...\n│ └─src/\n│   └─...\n└─src/\n  └─main.c\n```\n\nNow we can link with nonstdlib like this:\n```sh\ncd nonstdlib/src\nmake\n\ncd ../../src\ncc main.c -L../nonstdlib/src -I../nonstdlib/include -lnonstdlib\n```\n\nTo test that the library works you can copy this and verify that it compiles and that the assertions pass:\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n\n#include \"nonstdlib/nerror.h\"\n#include \"nonstdlib/nhashtable.h\"\n#include \"nonstdlib/nlist.h\"\n#include \"nonstdlib/nstring.h\"\n\nint main(void) {\n  // Small hashtable demo\n  ht_t *table = ht_init(8);\n  ht_put(table, \u0026string_of(\"key\"), \u0026string_of(\"value\"));\n\n  const string_t *result = ht_get(table, \u0026string_of(\"key\"));\n  ASSERT(result != NULL);\n  ASSERT(string_compare(\u0026string_of(\"value\"), result) == 0);\n\n  // Small list demo\n  typedef struct {\n    int x;\n    char *s;\n  } list_element;\n\n  list_t *list = list_init(8);\n  list_push_back(list, \u0026(list_element){.x = 10, .s = \"my list element\"});\n\n  const list_element *popped = list_pop_front(list);\n  ASSERT(popped != NULL);\n  ASSERT(popped-\u003ex == 10);\n  ASSERT(strcmp(popped-\u003es, \"my list element\") == 0);\n\n  ht_free(table);\n  list_free(list);\n\n  printf(\"All assertions passed, library is working as expected :)\\n\");\n}\n```\n\n## Modules\nList of currently implemented modules:\n- `narena.h`: An implementation of an arena allocator that simplifies memory management by grouping allocations into larger blocks instead of multiple smaller allocations with a convenient free function for freeing the entire block at once.\n- `nhashtable.h`: An implementation of the hashtable datastructure - associate a key with some given value with. O(1) insertion complexity, O(1) lookup complexity.\n- `nerror.h`: Contains some functions for handling typical errors and printing more useful debug information. Also has a custom assert macro that uses nonstdlib's error handling on error\n- `nlinked_list.h`: An implementation of the linked list datastructure - specifically a doubly ended linked list. O(1) insertion complexity, O(n) lookup complexity.\n- `nlist.h`: An implementation of the dynamic array datastructure - something akin to ArrayLists in java or lists in python. O(1) insertion complexity, O(1) lookup complexity.\n- `narray.h`: Some handy utilities for managing builtin C arrays.\n- `nstring.h`: Simple string interface that saves the length of strings instead of relying on nullbytes, as well as some handy utilities for managing strings.\n- `nsort.h`: Some sorting algorithms for builtin C arrays.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgremble0%2Fnonstdlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgremble0%2Fnonstdlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgremble0%2Fnonstdlib/lists"}