{"id":17874329,"url":"https://github.com/jomy10/defer","last_synced_at":"2025-03-21T22:31:51.318Z","repository":{"id":206222709,"uuid":"716124356","full_name":"Jomy10/defer","owner":"Jomy10","description":"A simple, single-header library which implements defer and autofree at compile-time in C/C++","archived":false,"fork":false,"pushed_at":"2024-10-20T12:22:15.000Z","size":9,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T11:52:01.273Z","etag":null,"topics":["autofree","c","cpp","defer","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/Jomy10.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-11-08T13:47:29.000Z","updated_at":"2025-01-09T18:46:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"302e9f0f-0ede-4211-809b-94cc0a781920","html_url":"https://github.com/Jomy10/defer","commit_stats":null,"previous_names":["jomy10/defer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jomy10%2Fdefer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jomy10%2Fdefer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jomy10%2Fdefer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jomy10%2Fdefer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jomy10","download_url":"https://codeload.github.com/Jomy10/defer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244166637,"owners_count":20409177,"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":["autofree","c","cpp","defer","single-header","single-header-lib","single-header-library"],"created_at":"2024-10-28T11:08:29.800Z","updated_at":"2025-03-21T22:31:50.914Z","avatar_url":"https://github.com/Jomy10.png","language":"C","readme":"# defer.h\n\nA simple, stb-style single-header library which adds a compile-time defer block and autofree attribute to C/C++.\n\n## Autofree\n\n```c\n{\n    autofree int* i = malloc(sizeof(int));\n    printf(\"%d\\n\", i);\n    // i is freed here\n}\n```\n\n## Defer\n\n```c\n{\n    struct MyStruct* s = MyStruct_create();\n    defer({\n        MyStruct_destroy(s);\n    });\n\n    printf(\"%p\\d\", s);\n    // s is freed here using MyStruct_destroy\n}\n```\n\n## Including the header\n\nAll info can be found in the header file, but to summarize:\n\nDo this:\n```c\n#define DEFER_IMPL\n```\nbefore you include this file in *one* C or C++ file to create the implementation.\n\ni.e. it should look like this:\n\n```c\n#include ...\n#include ...\n#include ...\n#define DEFER_IMPL\n#include \"defer.h\"\n```\n\n## License\n\nLicesed under MIT license, do what you want with it.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomy10%2Fdefer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjomy10%2Fdefer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomy10%2Fdefer/lists"}