{"id":17002076,"url":"https://github.com/sagiegurari/c_string_buffer","last_synced_at":"2025-04-12T06:22:05.617Z","repository":{"id":139264108,"uuid":"256505490","full_name":"sagiegurari/c_string_buffer","owner":"sagiegurari","description":"A simple string buffer for C","archived":false,"fork":false,"pushed_at":"2023-09-27T07:12:16.000Z","size":82,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T01:41:30.913Z","etag":null,"topics":["c","c-lib","c-library","string","string-buffer"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagiegurari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-04-17T13:07:10.000Z","updated_at":"2025-03-24T13:13:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c56cde0-92cf-480a-875c-fdfbafbbdbfa","html_url":"https://github.com/sagiegurari/c_string_buffer","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fc_string_buffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fc_string_buffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fc_string_buffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fc_string_buffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagiegurari","download_url":"https://codeload.github.com/sagiegurari/c_string_buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525811,"owners_count":21118753,"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":["c","c-lib","c-library","string","string-buffer"],"created_at":"2024-10-14T04:27:01.134Z","updated_at":"2025-04-12T06:22:05.589Z","avatar_url":"https://github.com/sagiegurari.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stringbuffer\n\n[![CI](https://github.com/sagiegurari/c_string_buffer/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/c_string_buffer/actions)\n[![Release](https://img.shields.io/github/v/release/sagiegurari/c_string_buffer)](https://github.com/sagiegurari/c_string_buffer/releases)\n[![license](https://img.shields.io/github/license/sagiegurari/c_string_buffer)](https://github.com/sagiegurari/c_string_buffer/blob/master/LICENSE)\n\n\u003e A simple string buffer for C.\n\n* [Overview](#overview)\n* [Usage](#usage)\n* [Contributing](.github/CONTRIBUTING.md)\n* [Release History](CHANGELOG.md)\n* [License](#license)\n\n\u003ca name=\"overview\"\u003e\u003c/a\u003e\n## Overview\nThis library provides a simple string buffer which allows adding different basic data types.\u003cbr\u003e\nIt can be used to generate large strings without the need to worry about memory allocation or type conversions.\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\n\n\u003c!-- example source start --\u003e\n```c\n#include \"stringbuffer.h\"\n#include \u003cstdio.h\u003e\n\n\nint main()\n{\n  // init the buffer with predefined size or with a provided size\n  // use stringbuffer_new for predefined size\n  struct StringBuffer *buffer = stringbuffer_new_with_options(\n    1024, // initial size\n    true  // allow resizing\n    );\n\n  // different append functions\n  stringbuffer_append(buffer, 'A');\n  stringbuffer_append_string(buffer, \"12345\");\n  stringbuffer_append_bool(buffer, true);\n  stringbuffer_append_short(buffer, 150);\n  stringbuffer_append_unsigned_short(buffer, 150);\n  stringbuffer_append_int(buffer, 150);\n  stringbuffer_append_unsigned_int(buffer, 150);\n  stringbuffer_append_long(buffer, 150);\n  stringbuffer_append_unsigned_long(buffer, 150);\n  stringbuffer_append_long_long(buffer, 150);\n  stringbuffer_append_unsigned_long_long(buffer, 150);\n  stringbuffer_append_string_with_options(\n    buffer,\n    \"12345\",\n    1, // offset\n    2  // length\n    );\n\n  // increase buffer size if needed to ensure capacity\n  // and prevent multiple reallocations in case of many\n  // append operations\n  stringbuffer_ensure_capacity(buffer, 10240);\n\n  // shrink the internal buffer to fit the exact value\n  // of the current content and prevent using more memory\n  // than needed.\n  stringbuffer_shrink(buffer);\n\n  // get a clone text value of the current buffer content\n  char *text = stringbuffer_to_string(buffer);\n  printf(\"The Text: %s\\n\", text);\n\n  // we can clear the content we have so far and reuse the\n  // string buffer instance\n  stringbuffer_clear(buffer);\n\n  bool is_empty = stringbuffer_is_empty(buffer);\n  printf(\"Is Empty: %d\\n\", is_empty);\n\n  // once done, free the buffer\n  stringbuffer_release(buffer);\n} /* main */\n```\n\u003c!-- example source end --\u003e\n\n## Contributing\nSee [contributing guide](.github/CONTRIBUTING.md)\n\n\u003ca name=\"history\"\u003e\u003c/a\u003e\n## Release History\n\nSee [Changelog](CHANGELOG.md)\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\nDeveloped by Sagie Gur-Ari and licensed under the Apache 2 open source license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fc_string_buffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagiegurari%2Fc_string_buffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fc_string_buffer/lists"}