{"id":20968943,"url":"https://github.com/lind026/ownership-checker","last_synced_at":"2026-03-05T13:04:04.590Z","repository":{"id":104038276,"uuid":"584774722","full_name":"linD026/Ownership-Checker","owner":"linD026","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-18T01:21:32.000Z","size":230,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T09:44:46.770Z","etag":null,"topics":["c","safety"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linD026.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,"zenodo":null}},"created_at":"2023-01-03T13:37:55.000Z","updated_at":"2023-08-21T10:34:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"3d846fa9-f5e5-4e6a-82ac-fdf0c38a0061","html_url":"https://github.com/linD026/Ownership-Checker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/linD026/Ownership-Checker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linD026%2FOwnership-Checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linD026%2FOwnership-Checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linD026%2FOwnership-Checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linD026%2FOwnership-Checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linD026","download_url":"https://codeload.github.com/linD026/Ownership-Checker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linD026%2FOwnership-Checker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30127227,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["c","safety"],"created_at":"2024-11-19T03:17:38.529Z","updated_at":"2026-03-05T13:04:04.571Z","avatar_url":"https://github.com/linD026.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ownership Checker for C Language\n\n## Build\n\n```bash\nmake                # Build the program\nmake verbose=1      # Debug mode\nmake clean          # Delete generated files\n```\n\n## Flags and Preprocessor\n\n**WARNING** Now we use the compiler, like gcc or clang, to preprocess the C\nsource for helping us handle the header and macro. But in the future, we\nwill handle it by ourselves.\n\n- `-P`: Analyzing the input file without preprocessing\n- `-C \u003ccompiler\u003e`: The compiler for preprocessing, the default is `gcc`\n- `-I \u003cdirectory\u003e`\n\n## Example\n\n```\n$ make\nOSC Analyzes file: tests/test_write.c\nOSC ERROR: Return the dropped object\n    |-\u003e tests/test_write.c:4:13\n    |        return (b + 1);\n    |                ^\n    +-\u003e Dropped at tests/test_write.c:3:18\n    |        function2(a, b, c);\n    |                     ^\nOSC NOTE: The object is declared as function2 argument: int __mut *b\nOSC ERROR: Don't write to the borrowed object\n    |-\u003e tests/test_write.c:11:15\n    |        a = *borrow = 3;\n    |                  ^\nOSC NOTE: The object is declared as function argument: int __brw *borrow\nOSC ERROR: Should release the end-of-life object\n    |-\u003e tests/test_write.c:17:6\n    |        }\n    |         ^\n    +-\u003e Set at tests/test_write.c:16:29\n    |            int __mut *scoped_ptr = \u0026a;\n    |                                ^\nOSC NOTE: The object is declared as function scope: int __mut *scoped_ptr\nOSC ERROR: Return the dropped object\n    |-\u003e tests/test_write.c:19:18\n    |        return mutable;\n    |                     ^\n    +-\u003e Dropped at tests/test_write.c:13:24\n    |        function2(a, mutable, borrow);\n    |                           ^\nOSC NOTE: The object is declared as function argument: int __mut *mutable\n```\n\nNow, we only check the ownership of the pointer that has the `__mut` or `__brw` attribute.\n\n## Sample\n\n```cpp\n// Warn on the pure pointer type in function prototype, i.e. `int *p` .\nint function(int *move, int __clone *clone, int copy)\n{\n    int *objA;\n    int /* __heap */  *objB_from_heap = malloc(); // obj, allocate memory from heap\n    \n    // change ownership\n    objA = objB_from_heap;\n    \n    // end of scope\n    // - end of lifetime: move, clone, copy\n    return *objA;\n    // pass value, don't have to consider the ownership\n}\n// Warning: don't have free() for obj, move, and clone\n```\n\n```cpp\nint *funcA(const int /* __immutable */ *imt, int __mut *mut, int __brw *brw)\n{\n    ...\n}\n// Warning: don't have free() for imt, and mut\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flind026%2Fownership-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flind026%2Fownership-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flind026%2Fownership-checker/lists"}