{"id":17136939,"url":"https://github.com/kernelsauce/dstr","last_synced_at":"2025-03-24T06:43:09.954Z","repository":{"id":5968289,"uuid":"7189866","full_name":"kernelsauce/dstr","owner":"kernelsauce","description":"Reference counted dynamic strings and string lists for C (C89 compliant).","archived":false,"fork":false,"pushed_at":"2013-05-20T19:53:49.000Z","size":495,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-29T12:25:15.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kernelsauce.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}},"created_at":"2012-12-16T11:17:19.000Z","updated_at":"2019-09-06T04:33:42.000Z","dependencies_parsed_at":"2022-09-03T08:01:23.776Z","dependency_job_id":null,"html_url":"https://github.com/kernelsauce/dstr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kernelsauce%2Fdstr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kernelsauce%2Fdstr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kernelsauce%2Fdstr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kernelsauce%2Fdstr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kernelsauce","download_url":"https://codeload.github.com/kernelsauce/dstr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245223997,"owners_count":20580362,"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":[],"created_at":"2024-10-14T20:05:47.968Z","updated_at":"2025-03-24T06:43:09.932Z","avatar_url":"https://github.com/kernelsauce.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"dstr\n====\n\n\u003cb\u003eReference counted dynamic string and string containers\u003c/b\u003e\n\nUse it to ease the work with strings in C. Doxygen documentation is available by generating it from source.\n\nAuthor: John Abrahamsen \u003cJhnAbrhmsn@gmail.com\u003e.\n\n\u003cb\u003eIts simple:\u003c/b\u003e\n\t\n```C\n\tdstr *str = dstr_with_initial(\"concat me\");\n\tdstr *str2 = dstr_with_initial(\" to me\");\n\t\n\tdstr_append(str, str2);\n        printf(\"%s\", dstr_from_dstr_to_cstr(str));\n\tdstr_decref(str);\n\tdstr_decref(str2);\n```\n\nContainers\n----------\n\nImplementations of both linked lists, dstr_list, and vectors, dstr_vector, are provided.\n\n\u003cb\u003eIt's also simple:\u003c/b\u003e\n\t\n```C\n\tdstr_vector *vector = dstr_vector_new();\n\tdstr_vector_push_back_decref(vector, dstr_with_initial(\"First string\"));\n\tdstr_vector_push_back_decref(vector, dstr_with_initial(\"Second string\"));\n\t\n\twhile(!dstr_vector_is_empty(vector)){\n\t\tdstr_print(dstr_vector_back(vector));\n\t\tdstr_vector_pop_back(vector);\n\t}\n\t\n\tdstr_vector_decref(vector);\n```\n\t\nNo more memory management is needed. dstr library provides functions for containers\nthat will either decrement reference or not, depending on usage.\n\t\nPerformance\n-----------\n\nAll benchmarks are done on Ubuntu 11.04 and Lenovo W510.\n\nStrings:\n\n```C\n    dstr *str = dstr_new();\n    int i;\n\n    for (i = 0; i \u003c 1000000; i++){\n        dstr_append_cstr(str, \"concat me onto something...\");\n    }\n\n    dstr_decref(str);\n```\n\nWithout DST_MEM_CLEAR defined (zero bytes previous used string buffers before\nfreeing):\n\n  Test: test_some_concating ... time used for 1000000 appends: 0 seconds 50 milliseconds. passed\n\nWith DST_MEM_CLEAR:\n\n  Test: test_some_concating ... time used for 1000000 appends: 0 seconds 660 milliseconds. passed\n\nVectors:\n\n```C\n    dstr *str = dstr_with_initial(\"append me\");\n    dstr_vector *vec = dstr_vector_new();\n    int i;\n\n    for (i = 0; i \u003c 1000000; i++){\n        dstr_vector_push_back(vec, str);\n    }\n\n    dstr_vector_decref(vec);\n    dstr_decref(str);\n```\n\nWithout DSTR_MEM_SECURITY  (boundary protection for operations get/set/remove operations):\n  - Test: test_vector_append_speed ... time used for 1000000 push_back to vector: 0 seconds 60 milliseconds. passed\n  - Test: test_vector_append_speed_no_prealloc ... time used for 1000000 push_back to vector: 0 seconds 70 milliseconds. passed\n  - Test: test_vector_append_front_speed ... time used for 20000 push_front to vector: 2 seconds 140 milliseconds. passed\n\nWith DSTR_MEM_SECURITY defined:\n  - Test: test_vector_append_speed ... time used for 1000000 push_back to vector: 0 seconds 70 milliseconds. passed\n  - Test: test_vector_append_speed_no_prealloc ... time used for 1000000 push_back to vector: 0 seconds 70 milliseconds. passed\n  - Test: test_vector_append_front_speed ... time used for 20000 push_front to vector: 2 seconds 140 milliseconds. passed\n\nLists:\n  - Test: test_list_speed ... time used for 1000000 insertion to list: 0 seconds 110 milliseconds. passed\n\nLicense\n-------\n\nCopyright 2012 John Abrahamsen \u003cjhnabrhmsn@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkernelsauce%2Fdstr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkernelsauce%2Fdstr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkernelsauce%2Fdstr/lists"}