{"id":20271305,"url":"https://github.com/itsyakub/leaky","last_synced_at":"2025-03-04T00:03:02.374Z","repository":{"id":197728110,"uuid":"698174464","full_name":"itsYakub/Leaky","owner":"itsYakub","description":"Single-header library for memory menagement","archived":false,"fork":false,"pushed_at":"2023-10-02T06:54:14.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T05:48:19.417Z","etag":null,"topics":["c","c-lang","c-language","c-language-programming","memory","memory-allocation","memory-management","single-header","single-header-lib","single-header-library"],"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/itsYakub.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}},"created_at":"2023-09-29T10:22:21.000Z","updated_at":"2024-08-23T19:18:57.000Z","dependencies_parsed_at":"2023-10-02T08:14:03.819Z","dependency_job_id":null,"html_url":"https://github.com/itsYakub/Leaky","commit_stats":null,"previous_names":["itsyakub/leaky"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsYakub%2FLeaky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsYakub%2FLeaky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsYakub%2FLeaky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsYakub%2FLeaky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsYakub","download_url":"https://codeload.github.com/itsYakub/Leaky/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241758955,"owners_count":20015250,"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":["c","c-lang","c-language","c-language-programming","memory","memory-allocation","memory-management","single-header","single-header-lib","single-header-library"],"created_at":"2024-11-14T12:37:29.480Z","updated_at":"2025-03-04T00:03:02.356Z","avatar_url":"https://github.com/itsYakub.png","language":"C","readme":"# Leaky\n\u003cb\u003eC / C++ Single-header library for memory menagement.\u003c/b\u003e\n\n# Example code\n```c\n#include \u003cstdlib.h\u003e\n\n#define LEAKY_IMPLEMENTATION\n#include \"leaky.h\"\n\nint main(void){\n    // This will cause a memory leak of size: sizeof(int) bytes\n    int* integer = malloc(sizeof(int));\n    *integer = 8;\n\n    // This will cause a memory leak of size: 2 * sizeof(float) bytes...\n    float* floatingValue = calloc(sizeof(float), 2);\n    floatingValue[0] = 3.14159f;\n    floatingValue[1] = 0.123f;\n\n    // ..unless You call the free() function!\n    free(floatingValue);\n\n    // This call is allocating the memory of size: 8 * sizeof(char) bytes...\n    char* sentance = malloc(8 * sizeof(char));\n\n    // ...which is the reallocated with the size: 16 * sizeof(char). The reallocation will cause a memory leak, bacause the previous char* was freed during the process\n    char* newSentance = realloc(sentance, 16 * sizeof(char));\n\n    // At the end of the program we have two memory leaks:\n    //      \u003e 1. *integer at line 8;\n    //      \u003e 2. *newSentance at line 23;\n    // Leaky will keep track of those values and, at the end of the program, it's going to give you a raport of every allocation, every freeing, how much memory you've allocated and freed and which variables cause the leaks!\n\n    return 0;\n}\n```\n\n# Description\nLeaky is a lightweight C/C++ single-header library designed for memory management in your programs. Unlike some libraries that introduce complex memory management idioms (e.g., RAII), Leaky takes a more straightforward approach. It diligently tracks memory allocation and deallocation, monitors memory consumption, and helps you identify potential memory leaks in your code.\n\nThis project draws significant inspiration from [namantam1's memory-leak-detector](https://github.com/namantam1/memory-leak-detector). While the original code served as a foundation, it has been redefined and refined to improve functionality, codebase cleanliness, and simplicity. Credit goes to the original author for their valuable work.\n\n# Information\n- **Original Author:** Leaky was inspired by the work of [namantam1](https://github.com/namantam1), and it leverages their repository, which can be found [here](https://github.com/namantam1/memory-leak-detector).\n- **Single-Header:** Leaky is designed as a `single-header library`, which means you can effortlessly integrate it into your project by simply including the `leaky.h` file.\n- **#LEAKY_IMPLEMENTATION:** To make Leaky functional in your project, you need to define the `LEAKY_IMPLEMENTATION` macro once within your source files. This macro includes the necessary function definitions used by Leaky. **Please note that defining `LEAKY_IMPLEMENTATION` multiple times can lead to issues, so ensure it's defined only once.**\n\n# TODO:\n- [X] implement `realloc`.\n- [ ] comment the codebase of the `leaky.h` file.\n- [ ] write better example code.\n- [ ] write tests.\n\n# Licence\nThis project uses the [MIT](https://github.com/itsYakub/Leaky/blob/main/LICENSE) Licence.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsyakub%2Fleaky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsyakub%2Fleaky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsyakub%2Fleaky/lists"}