{"id":28996460,"url":"https://github.com/superpuero/kawa_arena_allocator","last_synced_at":"2025-06-25T05:09:53.165Z","repository":{"id":300761725,"uuid":"1007066795","full_name":"superPuero/kawa_arena_allocator","owner":"superPuero","description":"Fast, single-header and modern, allocator solution for c++ 17","archived":false,"fork":false,"pushed_at":"2025-06-23T13:34:31.000Z","size":17,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-23T13:44:17.691Z","etag":null,"topics":["arena","arena-allocator","cpp","cpp17","game-development","memory"],"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/superPuero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-06-23T12:13:20.000Z","updated_at":"2025-06-23T13:34:34.000Z","dependencies_parsed_at":"2025-06-23T13:54:49.270Z","dependency_job_id":null,"html_url":"https://github.com/superPuero/kawa_arena_allocator","commit_stats":null,"previous_names":["superpuero/kawa_arena_allocator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/superPuero/kawa_arena_allocator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superPuero%2Fkawa_arena_allocator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superPuero%2Fkawa_arena_allocator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superPuero%2Fkawa_arena_allocator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superPuero%2Fkawa_arena_allocator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/superPuero","download_url":"https://codeload.github.com/superPuero/kawa_arena_allocator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superPuero%2Fkawa_arena_allocator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261808073,"owners_count":23212694,"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","cpp","cpp17","game-development","memory"],"created_at":"2025-06-25T05:09:52.459Z","updated_at":"2025-06-25T05:09:53.148Z","avatar_url":"https://github.com/superPuero.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏟 kawa::arena\\_allocator\n\n![language](https://img.shields.io/badge/C%2B%2B-17-blue.svg)\n![status](https://img.shields.io/badge/stability-stable-brightgreen)\n![license](https://img.shields.io/badge/license-MIT-green.svg)\n\n **kawa::arena\\_allocator** is a **single-header**, *zero-overhead* arena (stack) allocator for modern C++.\nIt delivers lightning-fast **push / pop** semantics, automatic pointer\nalignment, and a handly RAII **scoped** helper – no exceptions, no surprises.\n\n---\n\n## 🔧 Building \u0026 Integrating\n\n1. Add `arena_allocator.h` to your include path.\n2. Compile with **`-std=c++17`** (or `/std:c++17` on MSVC).\n\nThere are no other dependencies.\n\n---\n\n## ✨ Features\n\n* **O(1) push / pop** for trivially predictable performance.\n* **Alignment‑aware**: uses `std::align` internally – no UB.\n* **`scoped` RAII helper** – automatic rollback of nested allocations.\n* **Debug‑friendly**: assertions \u0026 platform‑specific `debugbreak()` in `_DEBUG` builds.\n* Works with **C++17** and later (GCC / Clang / MSVC).\n\n---\n\n## 🚀 Quick Start\n\n```cpp\n#include \"arena_allocator.h\"\n\nconstexpr std::size_t BYTES   = 1024;   // 1 KiB\nconstexpr std::size_t ENTRIES = 32;     // 32 push ops max\n\nkawa::arena_allocator arena{BYTES, ENTRIES};\n\nauto* i  = arena.push\u003cint\u003e();                    // typed push (default ctor)\nauto* v  = arena.push\u003cstd::vector\u003cint\u003e\u003e(10, 42); // ctor with (10, 42) as args\nvoid* raw = arena.push(64);                      // untyped push (64 bytes)\n\narena.pop(); // ← raw block (no dtor)\narena.pop(); // ← vector (dtor is called because vector is not trivially-destructable!)\n```\n\n### Scoped guard usage\n\n```cpp\n{\n    kawa::arena_allocator::scoped scope = arena.scope();\n\n    auto* big = scope.push\u003cdouble[128]\u003e();\n    scope.push(256);          // scratch buffer\n\n    // automatically rolled back when guard goes out of scope (calls destructors too)\n} // ← all allocations in scope are popped here\n```\n\n---\n\n## 📝 API Overview\n\n| Member                                          | Notes                                                    |\n| ----------------------------------------------- | ---------------------------------------------------------|\n| `arena_allocator(size_t bytes, size_t entries)` | create arena                                             |\n| `T* push\u003cT\u003e(Args\u0026\u0026...)`                         | reserve \u0026 in place construction of T with provided args  |\n| `void* push(size_t bytes)`                      | raw memory block                                         |\n| `void pop()`                                    | Pops the last push (LIFO) and calls destructor if needed |\n| `arena_appocator::scoped scope()`               | returns RAII guard for automatic roll-back               |\n| `size_t capacity() const`                       | total bytes available                                    |\n| `size_t occupied() const`                       | current bytes in use                                     |\n\n\u003e **Note**: `pop()` calls the destructor of non‑trivially destructible types.  \n\u003e For raw memory allocations (`push(size)`), no destructor is called.\n\n---\n\n```\n ┌──────────── arena_allocator ────────────┐\n │  _data                                 │\n │ ▼                                      │\n │ [ used ][ free ................. ]     │  ← raw buffer (LIFO)\n │          ▲                             │\n │      _current                          │\n │                                        │\n │  _entries → [16][32][8] …              │  ← stride stack\n └─────────────────────────────────────────┘\n```\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperpuero%2Fkawa_arena_allocator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperpuero%2Fkawa_arena_allocator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperpuero%2Fkawa_arena_allocator/lists"}