{"id":31793568,"url":"https://github.com/avicted/va_c_arena","last_synced_at":"2025-10-10T18:20:44.469Z","repository":{"id":306528240,"uuid":"1025510053","full_name":"Avicted/va_c_arena","owner":"Avicted","description":"va_c_arena is a C99/C11 arena memory management library designed to provide efficient memory allocation and deallocation. This library is structured as a single-header, stb-style implementation for easy integration and cross-platform use.","archived":false,"fork":false,"pushed_at":"2025-07-26T02:27:54.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-26T08:57:43.743Z","etag":null,"topics":["arena-allocator","c","stb"],"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/Avicted.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":"2025-07-24T11:11:04.000Z","updated_at":"2025-07-26T02:27:58.000Z","dependencies_parsed_at":"2025-07-26T08:57:47.058Z","dependency_job_id":"ac3e0b91-b682-41b9-895c-130f6093a19c","html_url":"https://github.com/Avicted/va_c_arena","commit_stats":null,"previous_names":["avicted/va_c_arena"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Avicted/va_c_arena","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avicted%2Fva_c_arena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avicted%2Fva_c_arena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avicted%2Fva_c_arena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avicted%2Fva_c_arena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Avicted","download_url":"https://codeload.github.com/Avicted/va_c_arena/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Avicted%2Fva_c_arena/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279004910,"owners_count":26083802,"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-10T02:00:06.843Z","response_time":62,"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":["arena-allocator","c","stb"],"created_at":"2025-10-10T18:20:42.785Z","updated_at":"2025-10-10T18:20:44.462Z","avatar_url":"https://github.com/Avicted.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# va_c_arena\n\nva_c_arena is a C99/C11 arena memory management library designed to provide efficient memory allocation and deallocation. This library is structured as a single-header, stb-style implementation for easy integration and cross-platform use.\n\n\u003e **Note:**  \n\u003e - The core arena allocator is fully C99-compliant.\n\u003e - **Aligned allocation (`arena_alloc_aligned`) and the provided tests/examples require C11 or newer** for features like `_Alignas`, `_Alignof`, and their macros (`VA_ALIGNAS`, `VA_ALIGNOF`).  \n\u003e - Compilation with `-std=c99` will fail if you use aligned allocation or the aligned examples/tests.  \n\u003e - Compilation with `-std=c11`, `-std=c17`, or `-std=c23` is fully supported.\n\n## Features\n\n- **Arena Memory Management**: Efficiently allocate and manage memory in blocks.\n- **Single-Header (stb-style)**: Just include one header `include/va_arena.h` and add `#define VA_ARENA_IMPLEMENTATION` in one source file.\n- **Cross-Platform**: Works on various operating systems without modification.\n- **Portable:** Uses only standard C (`malloc`, `realloc`, `free`); no platform-specific APIs like `mmap` or `VirtualAlloc`.\n- **Easy to Use API**: Simple functions for memory management that are easy to integrate into your projects.\n- **Unit Tested**: Includes tests for all API functions.\n- **Aligned Allocations**: Supports aligned allocations for types with strict alignment requirements (C11 or newer required).\n- **Expandable Arena**: Optionally grow the arena at runtime with `arena_expand`.\n\n## Requirements\n\n- **C99 compiler** for the core arena functionality.\n- **C11 or newer compiler** only for aligned allocations and tests/examples using `VA_ALIGNAS`/`VA_ALIGNOF`.\n- Standard C library.\n\n## Example (Aligned Allocation, C11+)\n\n```c\n#include \u003cstdio.h\u003e\n#include \u003cstdalign.h\u003e\n\n#define VA_ARENA_IMPLEMENTATION\n#include \"va_arena.h\"\n\ntypedef struct {\n    VA_ALIGNAS(32) int id;\n    VA_ALIGNAS(32) double position[3];\n    VA_ALIGNAS(32) char name[32];\n} Entity;\n\nint main(void) {\n    Arena *arena = arena_create(4096);\n    Entity *entities = (Entity *)arena_alloc_aligned(arena, sizeof(Entity) * 10, 32);\n    if (!entities) {\n        fprintf(stderr, \"Failed to allocate aligned entities\\n\");\n        arena_destroy(\u0026arena);\n        return 1;\n    }\n    // Use entities...\n    arena_destroy(\u0026arena);\n    return 0;\n}\n```\n\n## Alignment and Thread Safety\n\n- **Alignment:** `arena_alloc` returns memory aligned at least to `alignof(max_align_t)` (C11+) or `_Alignof(max_align_t)` (C11/C17). For stricter alignment, use `arena_alloc_aligned` (requires C11 or newer).\n- **Thread Safety:** This arena implementation is **not thread-safe**. If you need to use an arena from multiple threads, you must provide your own synchronization.\n\n\n## Arena Expansion and Pointer Invalidation\n\nIf you use `arena_expand` to grow the arena, **all pointers previously returned by `arena_alloc` or `arena_alloc_aligned` may become invalid**. This is because the underlying memory block may be moved by `realloc`.  \n**After calling `arena_expand`, you must not use any pointers previously obtained from the arena.**\n\nExample:\n```c\nvoid *ptr = arena_alloc(arena, 128);\n// ... use ptr ...\narena_expand(arena, 4096);\n// DO NOT use ptr here! It may point to invalid memory.\n```\n\n## Building\n\nA sample `build.sh` is provided. To build all examples and tests:\n\n```sh\n./build.sh\n```\n\nTo test with different C standards (and verify alignment macro support):\n\n```sh\n./build.sh test-stds\n```\n\nTo run an example or test:\n\n```sh\n./build.sh example         # Run the basic example\n./build.sh aligned         # Run the aligned allocation example\n./build.sh tests           # Run the unit tests\n```\n\n## Running Valgrind\n\nTo check all executables for memory leaks with Valgrind:\n\n```sh\n./build.sh valgrind\n```\n\n--- \n\n## License\n\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favicted%2Fva_c_arena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favicted%2Fva_c_arena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favicted%2Fva_c_arena/lists"}