{"id":15049388,"url":"https://github.com/ccgargantua/arena-allocator","last_synced_at":"2025-09-09T23:48:13.375Z","repository":{"id":187331857,"uuid":"676209423","full_name":"ccgargantua/arena-allocator","owner":"ccgargantua","description":"Super small, simple, and (almost) completely C89-compliant single-header arena \"allocator\".","archived":false,"fork":false,"pushed_at":"2025-07-16T01:28:10.000Z","size":136,"stargazers_count":73,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-17T02:55:54.921Z","etag":null,"topics":["allocator","ansi","ansi-c","c","c89","c90","contributions-welcome","header-only","header-only-library","library","memory","simple","simple-project","single-header","single-header-library","small","small-project"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ccgargantua.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":"2023-08-08T17:12:55.000Z","updated_at":"2025-07-16T22:13:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"87599f57-46df-4190-9f37-06a5edde0e61","html_url":"https://github.com/ccgargantua/arena-allocator","commit_stats":null,"previous_names":["ccgargantua/arena-allocator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ccgargantua/arena-allocator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccgargantua%2Farena-allocator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccgargantua%2Farena-allocator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccgargantua%2Farena-allocator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccgargantua%2Farena-allocator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ccgargantua","download_url":"https://codeload.github.com/ccgargantua/arena-allocator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ccgargantua%2Farena-allocator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274384797,"owners_count":25275332,"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-09-09T02:00:10.223Z","response_time":80,"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":["allocator","ansi","ansi-c","c","c89","c90","contributions-welcome","header-only","header-only-library","library","memory","simple","simple-project","single-header","single-header-library","small","small-project"],"created_at":"2024-09-24T21:20:03.971Z","updated_at":"2025-09-09T23:48:13.119Z","avatar_url":"https://github.com/ccgargantua.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arena Allocator\nSingle-header arena allocator. C89 Compatible.\n\n---\n\n## Table of Contents\n\n1. **[About](#about)**\n  * 1.1 [Arena Allocators](#arena-allocators)\n  * 1.2 [C89 Compliance](#c89-compliance)\n  * 1.3 [Single-Header Libraries](#single-header-libraries)\n  * 1.4 [Disclaimer](#disclaimer)\n  * 1.5 [LICENSE](#LICENSE)\n2. **[Usage](#usage)**\n  * 2.1 [Including](#including)\n  * 2.2 [Functions and Macros](#functions-and-macros)\n3. **[Compatibility](#compatibility)**\n  * 3.1 [Compilers](#compilers)\n  * 3.2 [Operating Systems](#operating-systems)\n4. **[Contributing](#contributing)**\n  * 4.1 [Basic Guidelines](#basic-guidelines)\n  * 4.2 [Modifications to `arena.h`](#modifications-to-arenah)\n  * 4.3 [Testing](#testing)\n  * 4.4 [Code Style](#code-style)\n\n---\n\n## About\n\n### Arena Allocators\n\nArena allocators are a simple way to achieve easier, faster, and safer dynamic memory management by allowing multiple allocations to be freed as a group. This is done by allocating memory in large regions and then distributing portions of that memory as needed, reducing the amount of `malloc` calls (which are slow compared to simple pointer arithmetic).\n\nWhen you destroy the arena you also free it and all of its contents, reducing the amount of `free` calls which are also slow. Going further, you can clear arenas by simply resetting their memory pointers to `0`, allowing you to reuse them and eliminating the need for even more `malloc`'s and `free`'s.\n\nYou can learn more about arena/zone/region allocators by reading this [fantastic article](https://www.rfleury.com/p/untangling-lifetimes-the-arena-allocator).\n\n### C89 Compliance\n\nI'll keep this short. This is not completely C89 compliant due to representing pointers as integers, something that cannot be done if strictly following C89 due to lack of `uintptr_t` I am maintaining C89 compliance for fun, not because I use it. I personally am a C11 enjoyer. If you think C89 is the only way, well, good for you! But you're wrong.\n\n### Single-Header Libraries\n\nWhenever I share this project with other programmers, one of the most common responses I receive is something along the lines of: *You should NEVER put implementation/logic code in a header file!* I take issue with this statement for three reasons...\n\n1. It shows that an outdated and, by consequence, harmful construct is still being enforced in the education system, which is where said construct is usually introduced.\n\n2. Very rarely does the person making this statement have an actual reason for believing it. Does this person ever think about *why* they should \"NEVER put implementation/logic code in a header file\"? Simply regurgitating what they've heard without any basis for *why* they chose to agree with it does not help me in any way, and this person should not expect me to just accept it as they have done.\n\n3. The largest and most valid criticism of header-only/single-header libraries is that a change to the header requires re-compilation of all files that include it. In the case of my project, making changes to `arena.h`, even though the actual implementation is only contained in the translation unit that `#define`'s the `ARENA_IMPLEMENTATION` macro, will result in the rebuild of all files that include it. The solution? Once `arena.h` is in the desired state, stop making changes!\n\nLinking is sluggish and complicated. Many beginners often times struggle with learning the linking process, and they are also the biggest culprit when it comes to writing unsafe code. This alone is enough reason for me to make this arena allocator a header-only library. My code (in its current state) is very small, roughly 300 lines. Why would I make you build and link such a small implementation when you could simply `#include` it once and start using it out of the box? If you really have a problem with it, this allocator in the single-header format does not prevent you from following the source+header construct if you so desire. Heck, feel free to fork it and make it source+header, it's open source for a reason!\n\n### Disclaimer\nThis does not implement a kernel-level allocator, but instead wraps `malloc` and `free` (standard library or custom, your choice).\n\n\n### LICENSE\nWhile I do believe software should be open source, I don't believe it would ethical to require software that uses this library to also be open source. In the modern age of technology and the current state of the world, writing memory-safe code is more important than ever. For this reason, this software is licensed under the Apache License Version 2.0. You are strongly encouraged to read the `LICENSE` (included below, in `arena.h`, and its own file in this repo) if you are considering using the software, unless you believe you are 100% familiar with the terms and conditions.\n\n```\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n\n   Copyright 2024 Carter Dugan\n```\n\n---\n\n## Usage\nDocumentation for the arena allocator can all be found in `arena.h`. There is a comment at the top of the header file with quick instructions for usage for your convenience.\n\n### Including\nFor **one file in one translation unit**, you need the following:\n```c\n#define ARENA_IMPLEMENTATION\n#include \"arena.h\"\n```\n\nFrom that point, other files in other translation units can simply `#include \"arena.h\"` normally. There are additional macros you can define/use. See the section on [functions and macros](#functions-and-macros).\n\n### Types\n\nThere are two structs defined in `arena.h`. This lists each one along with its members.\n\n* **`Arena_Allocation`** The data structure for an arena allocation. Available only when `ARENA_DEBUG` is defined.\n  * `size_t index` The index in the arena in which the beginning of the allocation is located.\n  * `size_t size` The size of the memory allocated to this allocation in bytes.\n  * `char *pointer` The pointer associated for the allocation.\n  * `struct Arena_Allocation_s *next` The next allocation in the linked list.\n\n\n* **`Arena`** The data structure for an arena.\n  * `char *region` The region of allocated memory.\n  * `size_t index` The index of the region for the next pointer to be distributed.\n  * `size_t size` The size of memory allocated to the arena in bytes.\n  * `unsigned long allocations` The number of arena allocations that have been made. Only available when `ARENA_DEBUG` is defined.\n  * `Arena_Allocation *head_allocation` The first allocation made in the arena (used for a linked list). Only available when `ARENA_DEBUG` is defined.\n\n\n### Functions and macros\n```c\n/*\nAllocate and return a pointer to memory to the arena\nwith a region with the specified size. Providing a\nsize of zero results in a failure.\n\nParameters:\n  size_t size    |    The size (in bytes) of the arena\n                      memory region.\nReturn:\n  Pointer to arena on success, NULL on failure\n*/\nArena* arena_create(size_t size);\n\n\n/*\nReturn a pointer to a portion of specified size of the\nspecified arena's region. Nothing will restrict you\nfrom allocating more memory than you specified, so be\nmindful of your memory (as you should anyways) or you\nwill get some hard-to-track bugs. By default, memory is\naligned by alignof(size_t), but you can change this by\n#defining ARENA_DEFAULT_ALIGNMENT before #include'ing\narena.h. Providing a size of zero results in a failure.\n\nParameters:\n  Arena *arena    |    The arena of which the pointer\n                       from the region will be\n                       distributed\n  size_t size     |    The size (in bytes) of\n                       allocated memory planned to be\n                       used.\nReturn:\n  Pointer to arena region segment on success, NULL on\n  failure.\n*/\nARENA_INLINE void* arena_alloc(Arena *arena, size_t size);\n\n\n/*\nSame as arena_alloc, except you can specify a memory\nalignment for allocations.\n\nReturn a pointer to a portion of specified size of the\nspecified arena's region. Nothing will restrict you\nfrom allocating more memory than you specified, so be\nmindful of your memory (as you should anyways) or you\nwill get some hard-to-track bugs. Providing a size of\nzero results in a failure.\n\nParameters:\n  Arena *arena              |    The arena of which the pointer\n                                 from the region will be\n                                 distributed\n  size_t size               |    The size (in bytes) of\n                                 allocated memory planned to be\n                                 used.\n  unsigned int alignment    |    Alignment (in bytes) for each\n                                 memory allocation.\nReturn:\n  Pointer to arena region segment on success, NULL on\n  failure.\n*/\nvoid* arena_alloc_aligned(Arena *arena, size_t size, unsigned int alignment);\n\n\n/*\nCopy the memory contents of one arena to another.\n\nParameters:\n  Arena *src     |    The arena being copied, the source.\n  Arena *dest    |    The arena being copied to. Must be created/allocated\n                      already.\n\nReturn:\n  Number of bytes copied.\n*/\nARENA_INLINE size_t arena_copy(Arena *dest, Arena *src);\n\n\n/*\nReset the pointer to the arena region to the beginning\nof the allocation. Allows reuse of the memory without\nrealloc or frees.\n\nParameters:\n  Arena *arena    |    The arena to be cleared.\n*/\nARENA_INLINE void arena_clear(Arena* arena);\n\n\n/*\nFree the memory allocated for the entire arena region.\n\nParameters:\n  Arena *arena    |    The arena to be destroyed.\n*/\nARENA_INLINE void arena_destroy(Arena *arena);\n\n\n/*\nReturns a pointer to the allocation struct associated\nwith a pointer to a segment in the specified arena's\nregion.\n\nParameters:\n  Arena *arena    |    The arena whose region should\n                       have a portion pointed to by\n                       ptr.\n  void *ptr       |    The ptr being searched for\n                       within the arena in order to\n                       find an allocation struct\n                       associated with it.\n*/\nArena_Allocation* arena_get_allocation_struct(Arena *arena, void *ptr);\n\n\n/*\nAdds an arena allocation to the arena's linked list of\nallocations under debug.\n\nParameters:\n  Arena *arena    |    The arena whose allocation list\n                       should be added to\n  size_t size     |    The size of the allocation being\n                       added.\n*/\nvoid arena_add_allocation(Arena *arena, size_t size);\n\n\n/*\nDeletes the arena's linked list of allocations under\ndebug.\n\nParameters:\n  Arena *arena    |    The arena whose allocation list\n                       is being deleted.\n*/\nvoid arena_delete_allocation_list(Arena *arena);\n```\n\nIn your code, you can define some optional macros. `ARENA_MALLOC`, `ARENA_FREE` and `ARENA_MEMCPY` can be assigned to alternative `malloc`-like, `free`-like, and `memcpy`-like functions respectively, and `arena.h` will use them in place of standard library functions. You can access additional debug functionality for keeping track of allocations by defining `ARENA_DEBUG`. Finally, you can also specify a default value for allocation alignment by defining a value for `ARENA_DEFAULT_ALIGNMENT`. See below for examples.\n\n```c\n// All of these are optional\n\n// Replace standard library functions\n#define ARENA_MALLOC \u003cstdlib_malloc_like_allocator\u003e\n#define ARENA_FREE \u003cstdlib_free_like_deallocator\u003e\n#define ARENA_MEMCPY \u003cstdlib_memcpy_like_copier\u003e\n\n// for debug functionality:\n#define ARENA_DEBUG\n\n// If you would like to change the default alignment for\n// allocations:\n#define ARENA_DEFAULT_ALIGNMENT \u003calignment_value\u003e\n```\n\nThere is also a macro for determining alignment of types. Like everything else, it is also C89-friendly, although when compiling under C11 it will use `stdalign.h`'s `alignof`.\n\n```c\nARENA_ALIGNOF(type) // Gives alignment of `type`\n```\n\n---\n\n## Compatibility\n\nThe code was written to build with any compiler that supports the C89 standard and run on any platform. However, there are some issues with building on Windows with the `Makefile`. Please read all of the below information.\n\n### Compilers\n\nThe tests and examples have been compiled and successfully run under the following compilers and versions:\n\n* Clang 17\n* GCC 13.2\n* tcc 0.9.27\n* MSVC 17.8\n\n### Operating Systems\n\nThe tests and examples were compiled and successfully run on the following operating systems:\n\n* Ubuntu 22.04\n* Windows 10\n\n**NOTE** The Makefile currently has not been configured to work on Windows when running `$ make test` due to the use of valgrind and the absense of `.exe` extensions. This should be a simple fix and is on my TODO list (feel free to open an issue and fix this yourself!).\n\n---\n\n## Contributing\n\n### Basic Guidelines\n\nThis project has very simple guidelines for contributing.\n\n * For any **contributions to the code of `arena.h`**, please open a pull request only if you are **addressing an issue** to fulfill a **feature request or fix a bug**. Follow the code style and run the automated tests before opening a pull request. All tests must be passed.\n\n * For **feature requests** or **bugs**, please **open an issue**. You can then address this issue yourself.\n\n * For any **anything else**, open an issue and we will discuss it.\n\n### Modifications to `arena.h`\n\nAt the moment there is no documentation for the code style, but it should be relatively simple enough to pick up on through reading existing code for most things. If you are having trouble, feel free to open an issue for a FR. If it already exists, comment on it describing what you are confused by.\n\n* If you modify `arena.h` whatsoever, you must run the tests. See the next section.\n\n* If you add a feature within `arena.h`, you must create an adequate test or tests within `test.c`.\n\n* If you add a feature within `arena.h`, you must *should* an adequate example in `code_examples/` **and** add it to the `makefile`, but it is not required.\n\n### Testing\n\nIf you change `arena.h` whatsoever, **run the tests before opening a PR**. If you open a PR with modifictions to the code and the tests don't all pass, make a comment on your PR stating which test you believe is wrong and is preventing you from passing all of the tests. If any test fails and your PR doesn't have a comment that claims to correct a failed test, your PR will be ignored closed.\n\nOutside of addressing bugs and feature requests, fulfilling a feature request or bug fix for functionality within `arena.h` permits modifying or adding relevant testing code within `test.c`, and you must do so if you want your PR to be acknowledged. There is documentation for testing code within `test.c` at the top of the file in the form of comments.\n\nThe tests must also pass through valgrind leak-free, and `arena.h` **must** be C89 compliant*. You should check this using the `Makefile`, but if for some reason you can't or don't want to, compile `test.c` with\n\n(See note in [C89-Compliance](#c89-compliance))\n\n```\n-Werror -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement\n```\n\nAnd for compliance, compile `test_compliance.c` with\n\n```\n-pedantic -std=c89 -Werror -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement\n```\n\nAs I said, you can do all of this with the `Makefile`\n\n```\n$ make test\n```\n\n### Code Style\n\n* **Identifiers**\n  * **Variables** should be lowercase and snake case, eg `variable_name`. For **pointers**, the asterisk (`*`) should be attached to the variable name, not the type, eg `type *variable_name`.\n  * **Functions**, like variables, should be lowercase and snake case, eg `type function_name(p1, p2, ...)`. In the case of pointers, the asterisk (`*`) should be attached to the type for density, eg `type* function_name(p1, p2, ...)`. Functions should have a forward declaration with a comment for documentation above it around the top of the file, make sure the order relative to other functions is consistent.\n  * **Struct, enum, and union** identifiers should be pascal case, eg `struct StructName`. They should be typedef'd and located around the top of the header file.\n  * **Macros** should be all caps and snakecase, beginning with `ARENA_`, eg `ARENA_MACRO_NAME`. **Please avoid adding macros without consulting me first**. Feel free to make changes to existing macros, though.\n\n* **White space** is based on relevance of a line of code to those around it. If you don't understand what these points mean, please look at the code. It should be formatted as follows:\n  * A single newline separating closely related code.\n  * Two newlines separating unrelated code within the same scope or tag type.\n  * Three newlines separating code within different function scopes, tag types, and blocks of preprocessor directives.\n\n* **Error checking** should be done whenever possible and mimic the behavior of standard library implementations, such as returning `NULL` on error in functions that return pointers or returning integer error values from integer functions. You should use **early error checking**, which means checking for errors as soon as they could be produced, eg. checking for a `NULL` returned after a failed `malloc` call.\n\n* **Comments** should describe *why* you did something, not *what* it is that you did. In other words, your code should be self-explanatory. Documentation for functions in the form of comments should be located above the function in the following format:\n\n```c\n/*\nDescription of function, description of function description of function.\nDescription of function description of function, description of function\ndescription of function.\n\nParameters:\n  paramter1_type paramter1_name    |    Description of parameter 1, description\n                                        of parameter one description of paramter\n                                        1.\n  paramter2_type paramter2_name    |    Description of parameter 2, description\n                                        of parameter one description of paramter\n                                        2.\nReturn:\n  Description of return value, description of return value description of return value.\n*/\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccgargantua%2Farena-allocator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fccgargantua%2Farena-allocator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fccgargantua%2Farena-allocator/lists"}