{"id":24881916,"url":"https://github.com/stepainpy/common-da","last_synced_at":"2026-07-03T02:03:03.976Z","repository":{"id":275261858,"uuid":"925576277","full_name":"Stepainpy/common-da","owner":"Stepainpy","description":"Implement common dynamic array type for C99 and later","archived":false,"fork":false,"pushed_at":"2025-03-19T20:48:07.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T07:49:29.416Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Stepainpy.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":"2025-02-01T07:37:27.000Z","updated_at":"2025-03-19T20:48:11.000Z","dependencies_parsed_at":"2025-06-15T20:19:15.201Z","dependency_job_id":"45f63732-8d90-4416-b892-1e22d7233671","html_url":"https://github.com/Stepainpy/common-da","commit_stats":null,"previous_names":["stepainpy/common-da"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Stepainpy/common-da","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Fcommon-da","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Fcommon-da/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Fcommon-da/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Fcommon-da/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Stepainpy","download_url":"https://codeload.github.com/Stepainpy/common-da/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Stepainpy%2Fcommon-da/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35069183,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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":[],"created_at":"2025-02-01T12:14:23.680Z","updated_at":"2026-07-03T02:03:03.952Z","avatar_url":"https://github.com/Stepainpy.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Common dynamic array\n\n## Overview\n\nImplementation dynamic array without depend the stored type. Object of type `da_t` save information about stored type (size and destruction function). When creating new `da` need set size of stored type and destructor if necessary.\n\n## Usage\n\n### Creating and using `da`\n\n``` c\nDA_CREATE_VAR(da, int, NULL); // place 'da' to stack\n/* ... some code ... */\nsize_t length = da.count; // access to field\nda_some_func(\u0026da, ...); \n```\n\n### Access to items\n\n- `da_at_fwd` - get pointer to item by index as return value\n- `da_at` - get pointer to item by index\n- `da_front` - get pointer to first item\n- `da_back` - get pointer to last item\n\n### Adding items\n\n- `da_insert` - insert value from pointer into position by index\n- `da_insert_imm` - insert value into position by index\n- `da_insert_many` - insert values from array into position by index\n- `da_push_back` - insert value from pointer into last position\n- `da_push_back_imm` - insert value into last position\n- `da_push_back_many` - insert value from array into last position\n\n### Removing items\n\n- `da_remove` - remove item by index\n- `da_remove_many` - remove items by indexes in range\n- `da_pop_back` - remove last item\n- `da_pop_back_many` - remove N-last items\n\n### Deletion items\n\n- `da_clear` - remove all items and save capacity\n- `da_destroy` - remove all items and free allocated memory\n\n### Capacity manipulation\n\n- `da_reserve` - reserve memory for N-items\n- `da_shrink_to_fit` - deallocate free capacity\n\n## Pre-include macros\n\n- `DA_IMPLEMENTATION` - add definition of functions\n- `DA_DEF` - User-provided attributes (as an example: `__declspec(dllexport)`)\n- `DA_INIT_CAP` - default start capacity for empty `da`\n\n## Provided macros\n\n- `DA_CREATE_VAR` - initialize new variable of type `da_t`\n- `DA_FOREACH` - expand to header (`for` with brackets) for for-loop and iterable by `da`\n- `DA_VOID_FOREACH` - as `DA_FOREACH`, but use `void *` iterator variable\n\n## Example\n\nPrint command line arguments\n\n``` c\n#define DA_IMPLEMENTATION\n#include \"common_da.h\"\n#include \u003cstdio.h\u003e\n\nint main(int argc, char** argv) {\n    DA_CREATE_VAR(args, const char*, NULL);\n    da_error_t err;\n\n    err = da_push_back_many(\u0026args, argv, argc);\n    if (err != dae_success) { // error check\n        fprintf(stderr, \"%s\\n\", da_error_to_str(err));\n        return 1;\n    }\n\n    size_t i = 0;\n    printf(\"argc = %zu\\n\", args.count);\n    DA_FOREACH(const char*, arg, \u0026args) {\n        printf(\"argv[%zu] = %s\\n\", i++, *arg);\n    }\n\n    da_destroy(\u0026args);\n    return 0;\n}\n```\n\nPossible output\n``` console\n$ ./main foo bar baz\nargc = 4\nargv[0] = main.exe\nargv[1] = foo\nargv[2] = bar\nargv[3] = baz\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepainpy%2Fcommon-da","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstepainpy%2Fcommon-da","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstepainpy%2Fcommon-da/lists"}