{"id":27742381,"url":"https://github.com/aceinetx/ezheap","last_synced_at":"2025-04-28T16:40:00.957Z","repository":{"id":287586682,"uuid":"868432129","full_name":"aceinetx/EZHeap","owner":"aceinetx","description":"easy heap with no need to free","archived":false,"fork":false,"pushed_at":"2025-04-12T16:19:58.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T17:29:50.235Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aceinetx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-10-06T11:26:03.000Z","updated_at":"2025-04-12T16:20:01.000Z","dependencies_parsed_at":"2025-04-12T17:30:03.191Z","dependency_job_id":"3ca9bf82-67b3-4cf8-adb9-eb4e923e31e3","html_url":"https://github.com/aceinetx/EZHeap","commit_stats":null,"previous_names":["aceinetx/ezheap"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceinetx%2FEZHeap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceinetx%2FEZHeap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceinetx%2FEZHeap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aceinetx%2FEZHeap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aceinetx","download_url":"https://codeload.github.com/aceinetx/EZHeap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251347491,"owners_count":21575092,"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":[],"created_at":"2025-04-28T16:40:00.049Z","updated_at":"2025-04-28T16:40:00.943Z","avatar_url":"https://github.com/aceinetx.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EZHeap\nEasy heap with no need to free, eliminating all memory leaks\n## This is not a heap implementation\nThis acts like a provider to ```malloc()```/```free()```\n## Example\n```c\n#include \u003cezheap.h\u003e\n#include \u003cstdio.h\u003e\n\nvoid func()\n{\n  // as ezheap is initalized, you can use it anywhere\n  int *y = new(int);\n  *y = 69;\n  printf(\"%d\\n\", *y);\n}\n\nvoid hello_world()\n{\n  // you can also allocate strings!\n  char *str = new_str(\"Hello, world!\");\n  printf(\"%s\\n\", str);\n}\n\nvoid alloc_bytes()\n{\n  // if you really need it, you can allocate raw bytes\n  void *bytes = new(char[5]); // acts the same as malloc(5)\n}\n\nint main()\n{\n  ezheap_init();\n\n  int *x = new(int);\n  *x = 123;\n  printf(\"%d\\n\", *x);\n\n  func();\n  hello_world();\n  alloc_bytes();\n\n  // this free's all allocated variables, so no need to do free()\n  ezheap_destruct();\n}\n```\n## Notice\nDo not use malloc() if you want to use ezheap, ezheap will not be able to free it\u003cbr\u003e\nDo not use free() on ezheap allocated variable, this will result in a double free when ezheap_destruct() is called\n## Macros\n- ```ezheap_init()```: initalizes ezheap\n- ```new(x)```: basically ```malloc(N)```, but expands to ```malloc(sizeof(N))```\n- ```new_str(x)```: basically ```new```, but copies ```x``` to a newly allocated variable\n- ```ezheap_destruct()```: destructs ezheap and free's all heap allocated variables (that are created using ```new``` or ```new_str```)\n- ```__ezheap_stdmalloc(x, y)```: basically ```malloc(x)```, but increments ```y-\u003eallocs```, needed for debug info\n- ```__ezheap_stdfree(x, y)```: basically ```free(x)```, but increments ```y-\u003efree```, needed for debug info\n- ```ezheap_dbg_info()```: prints debug info (can only be called if EZHEAP_DBG is defined)\n## Functions\n#### Public functions:\n- ```void *__ezheap_malloc_errsafe(size_t __size, ezheap_t *__ezheap)```: Allocate a variable that will be free'd when ```ezheap_destruct()``` is called. (Will ```abort()``` when ```malloc()``` fails)\n- ```void *__ezheap_malloc_str_errsafe(size_t __size, const char *__str, ezheap_t *__ezheap)```: Allocate a variable that will be free'd when ```ezheap_destruct()``` is called, and copy __str to it. . (Will ```abort()``` when ```malloc()``` fails)\n- ```void __ezheap_cleanup(ezheap_t *__ezheap)```: Cleanup ezheap and free all heap allocated variables\n- ```void __ezheap_debug_info(ezheap_t *__ezheap)```: Print debug info\n#### Private functions:\n- ```void *__ezheap_malloc(size_t __size, ezheap_t *__ezheap)```: Allocate a variable that will be free'd when ```ezheap_destruct()``` is called. Can return NULL\n## Checking for memory leaks\nYou can use valgrind, but if you have EZHEAP_DBG defined, you can use the ```ezheap_dbg_info()``` macro after ```ezheap_destruct()```, this will print all ```malloc()``` and ```free()``` usages\n## Why\n- Just because\n- ... because I can\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceinetx%2Fezheap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faceinetx%2Fezheap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faceinetx%2Fezheap/lists"}