{"id":21224479,"url":"https://github.com/eignnx/dynarray","last_synced_at":"2025-10-26T23:07:09.456Z","repository":{"id":103899652,"uuid":"119754177","full_name":"eignnx/dynarray","owner":"eignnx","description":"A generic dynamic array implementation in C.","archived":false,"fork":false,"pushed_at":"2025-05-06T15:45:14.000Z","size":60,"stargazers_count":27,"open_issues_count":5,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-10T19:55:24.899Z","etag":null,"topics":["c","generics","vector"],"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/eignnx.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":"2018-01-31T22:55:40.000Z","updated_at":"2025-07-09T05:44:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed987993-ae3d-4981-a13a-f5b91025e9ad","html_url":"https://github.com/eignnx/dynarray","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eignnx/dynarray","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eignnx%2Fdynarray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eignnx%2Fdynarray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eignnx%2Fdynarray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eignnx%2Fdynarray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eignnx","download_url":"https://codeload.github.com/eignnx/dynarray/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eignnx%2Fdynarray/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281185454,"owners_count":26457747,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","generics","vector"],"created_at":"2024-11-20T22:58:33.684Z","updated_at":"2025-10-26T23:07:09.451Z","avatar_url":"https://github.com/eignnx.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynarray\nA generic dynamic array implementation in C. A dynarray of type `T` can be passed to any function that operates on vanilla `T` arrays. Inspiration taken from [this article](https://solarianprogrammer.com/2017/01/08/c99-c11-dynamic-array-mimics-cpp-vector-api-improvements/) by [solarianprogrammer](https://solarianprogrammer.com/).\n\n## Example Usage\n\n```c\n#include \"dynarray.h\"\n\nint *v = dynarray_create(int);\n\nfor (int i = 0; i \u003c 10; i++) {\n    dynarray_push(v, i);\n    dynarray_push_rval(v, 100 - i);\n}\n\nfor (int i = 0; i \u003c dynarray_length(v); i++) {\n    printf(\"v[%d] -\u003e %d\\n\", i, v[i]);\n}\n\ndynarray_destroy(v);\n```\nOutput:\n```\nv[0] -\u003e 0\nv[1] -\u003e 100\nv[2] -\u003e 1\nv[3] -\u003e 99\n...\nv[18] -\u003e 9\nv[19] -\u003e 91\n```\n\n## Memory Layout\nThe array is heap-allocated and is prefixed with a three-field header containing the buffer's `capacity`, `length`, and `stride`.\n\n* The `stride` is calculated at creation time as `sizeof(T)` where `T` is the datatype you intend to store.\n* The `capacity` field stores the buffer's size.\n* The `length` field keeps track of the number of elements stored in the buffer.\n\nMacros defined in [`dynarray.h`](dynarray.h) allow the `capacity`, `length`, and `stride` attributes to be accessed.\n\nA dynarray is referred to _only_ by a pointer to the first element in its buffer. **This allows a dynarray to be passed to any function that operates on regular C-arrays.**\n\n![memory layout](images/dynarray-memory-layout.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feignnx%2Fdynarray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feignnx%2Fdynarray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feignnx%2Fdynarray/lists"}