{"id":18537272,"url":"https://github.com/amateur80lvl/arena","last_synced_at":"2025-08-16T01:14:15.535Z","repository":{"id":250812383,"uuid":"835136470","full_name":"amateur80lvl/arena","owner":"amateur80lvl","description":"Arena allocator","archived":false,"fork":false,"pushed_at":"2024-07-30T04:17:35.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-26T03:42:04.602Z","etag":null,"topics":["arena","arena-allocator"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amateur80lvl.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}},"created_at":"2024-07-29T08:30:17.000Z","updated_at":"2024-07-30T04:17:39.000Z","dependencies_parsed_at":"2024-07-30T07:57:30.979Z","dependency_job_id":"11d29e54-a25e-4cad-b47b-da1a6c1789d4","html_url":"https://github.com/amateur80lvl/arena","commit_stats":null,"previous_names":["amateur80lvl/arena"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amateur80lvl%2Farena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amateur80lvl%2Farena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amateur80lvl%2Farena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amateur80lvl%2Farena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amateur80lvl","download_url":"https://codeload.github.com/amateur80lvl/arena/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239255294,"owners_count":19608253,"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","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":["arena","arena-allocator"],"created_at":"2024-11-06T19:37:41.053Z","updated_at":"2025-02-17T07:42:29.634Z","avatar_url":"https://github.com/amateur80lvl.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arena allocator\n\n## Features\n\n* multiple regions\n* allocated values are properly aligned\n* `mmap` as underlying allocator\n\nThe capacity of arena itself and all its regions is always multiple\nof page size.\n\nC23 is required. Just because I love **nullptr**.\nPlus, GNU extensions are required for `mmap`.\n\nIn notoriously stable Devuan this can be compiled with\n```bash\nclang-16 --std=gnu2x\n```\n(as of July 2024)\n\n## How to use\n\n```c\n#include \u003cstdio.h\u003e\n#include \"arena.h\"\n\nint main(int argc, char* argv[])\n{\n    Arena *arena = create_arena(0);\n\n    for(int i = 0; i \u003c 500; i++) {\n        arena_alloc(arena, 3, long long);\n    }\n\n    arena_fit(arena, 10, char);\n    arena_fit(arena, 3000, char);\n\n    arena_print(arena);\n    delete_arena(arena);\n}\n```\n\n## API\n\n```c\nArena* create_arena(size_t capacity);\n```\nCreate new arena with desired capacity\nor at least one page.\n\nThe capacity of subsequent regions will be\nsame capacity unless adjusted with `set_region_capacity`.\n\n```c\nvoid delete_arena(Arena* arena);\n```\nFree arena and all its regions.\n\n```c\nvoid set_region_capacity(Arena* arena, size_t capacity);\n```\nSet desired capacity for newly created regions.\n\n```c\nvoid* arena_alloc(Arena* arena, size_t num_elements, element_type_name);\n```\nAllocate properly aligned `num_elements` from the last region.\nIf the last region has no space available, allocate new region.\n\n```c\nvoid* arena_fit(Arena* arena, size_t num_elements, element_type_name);\n```\nTry to find a region with sufficient free space\nand allocate from it.\nIf no region has space available, allocate new region.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famateur80lvl%2Farena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famateur80lvl%2Farena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famateur80lvl%2Farena/lists"}