{"id":18616533,"url":"https://github.com/ronflima/zapalloc","last_synced_at":"2025-11-03T06:30:38.819Z","repository":{"id":71262923,"uuid":"76077945","full_name":"ronflima/zapalloc","owner":"ronflima","description":"Fast memory allocation routines for fixed size memory blocks","archived":false,"fork":false,"pushed_at":"2018-10-26T17:43:14.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-27T03:25:43.207Z","etag":null,"topics":["alloc","hacktoberfest","stdc"],"latest_commit_sha":null,"homepage":null,"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/ronflima.png","metadata":{"files":{"readme":"README","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-09T23:27:17.000Z","updated_at":"2019-10-15T19:34:53.000Z","dependencies_parsed_at":"2023-03-01T12:30:49.785Z","dependency_job_id":null,"html_url":"https://github.com/ronflima/zapalloc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronflima%2Fzapalloc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronflima%2Fzapalloc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronflima%2Fzapalloc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ronflima%2Fzapalloc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ronflima","download_url":"https://codeload.github.com/ronflima/zapalloc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239412505,"owners_count":19634016,"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":["alloc","hacktoberfest","stdc"],"created_at":"2024-11-07T03:35:35.062Z","updated_at":"2025-11-03T06:30:38.767Z","avatar_url":"https://github.com/ronflima.png","language":"C","readme":"# zapalloc\n[![Build Status][travis-badge]][travis-url]\n[![License][mit-badge]][mit-url]\n\n## The irresponsible memory allocator\nFast memory allocation routines for fixed size memory blocks. This small library\nis intended to provide fast allocation and memory reusage when fixed size memory\nblocks are needed. This assumption makes this library not suitable for general\nusage and is specific for several small scenarios where memory is needed in\nblocks of the same size.\n\nYou can create several contexts, however, each one taking care of a block of a\ndifferent size.\n\nThis is not a memory debugger, but an attempt to optimize memory allocations by\ngiven the opportunity to alloc large amounts of memory and manage usage for you.\n\n## Fast or Crash\n\nThis library was created with this in mind: be fast or crash. There is no memory\ndebugging, no memory protection, no thread protection, no nothing. So, if your\nsoftware invade memory, it will crash. So, be careful.\n\n# Simple, stupid\n\nThis library was built over STDC malloc/calloc/realloc functions at this\nversion. In the future, it will replace, internally, STDC functions in favor of\nsystem calls that can be faster. It was designed to minimize system calls when\nreturning memory to the user. Algorithms are really simple and are designed for\nspeed.\n\n# Concepts\n\nAll memory is attached to a _context_. A context manages a certain amount of\nmemory which is defined during its initialization. If you request more memory\nthan it was initialized, the library will increase the internal memory in order\nto return to you more memory, but using its initial definitions.\n\nDuring its initialization, you must provide the number of blocks and the size of\neach block. ZapAlloc will initialize your context with so much memory already\nallocated inside. For instance, let's say you asked for 1024 blocks of 2048\nbytes each. During initialization, ZapAlloc will create a poll of 1024 blocks,\nwith 2048 bytes each. Each call to alloc function will return to you a block\ncontaining 2048 bytes. When you request the 1025th block, ZapAlloc will create a\nnew poll containing more 1024 blocks of 2048 bytes each and return a 2048 bytes\nblock to you.\n\nThe ideia behind the scenes is to:\n\n- centralize all memory management on a single manageable place (the _context_);\n- request a lot of memory at once, but fewer times to the system, reducing the\nquantity of system calls, since system calls are too expensive.\n\n## Why don't rely on malloc itself?\n\nThe STDC _malloc_ function is great for general memory allocation. Some\nimplementations do change the process's core size in order to return memory to\nthe system, which is great for general purpose. However, if you want\nperformance, it is a great idea avoiding to call the system too many times. Each\nsystem call will cost you a lot of processing time, since your process will be\ninterrupted by the operating system in order to have it's core resized.\n\nSo, _zapalloc_ try to avoid those many system calls by allocating a lot of\nmemory at once and then managing the memory blocks in a simple fashion, so you\ncan have a great performance at the end.\n\n# License\n\nThis project is released under the MIT license. See [LICENSE](LICENSE) for details.\n\n[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[mit-url]: https://tldrlegal.com/license/mit-license\n[travis-badge]: https://travis-ci.org/ronflima/zapalloc.svg?branch=master\n[travis-url]: https://travis-ci.org/ronflima/zapalloc\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronflima%2Fzapalloc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fronflima%2Fzapalloc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fronflima%2Fzapalloc/lists"}