{"id":18994955,"url":"https://github.com/jweinst1/datablock","last_synced_at":"2026-05-08T04:11:57.347Z","repository":{"id":97722924,"uuid":"120356571","full_name":"jweinst1/DataBlock","owner":"jweinst1","description":"A C library for handling dynamic, binary chunks of data.","archived":false,"fork":false,"pushed_at":"2018-02-07T20:32:35.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-21T11:53:09.817Z","etag":null,"topics":["binary","bytes","c","database","datastructures"],"latest_commit_sha":null,"homepage":null,"language":"Objective-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/jweinst1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2018-02-05T20:18:03.000Z","updated_at":"2018-02-07T20:32:35.000Z","dependencies_parsed_at":"2023-03-16T08:01:07.263Z","dependency_job_id":null,"html_url":"https://github.com/jweinst1/DataBlock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jweinst1/DataBlock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jweinst1%2FDataBlock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jweinst1%2FDataBlock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jweinst1%2FDataBlock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jweinst1%2FDataBlock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jweinst1","download_url":"https://codeload.github.com/jweinst1/DataBlock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jweinst1%2FDataBlock/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268448362,"owners_count":24252019,"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-08-02T02:00:12.353Z","response_time":74,"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":["binary","bytes","c","database","datastructures"],"created_at":"2024-11-08T17:27:44.773Z","updated_at":"2026-05-08T04:11:52.321Z","avatar_url":"https://github.com/jweinst1.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DataBlock\n\n*A C library for handling dynamic, binary chunks of data.*\n\n`DataBlock` is a C-header library that provides a unique data structure called a `DataBlock`, intended for easy handling of chunks of bytes, or binary data. `DataBlock` is packaged as a header to make it easy to embed and include in your project.\n\n## Installation\n\nTo use DataBlock, simply include the `src/Datablock.h` file in the source directory.\n\n### Tests\n\nTo build the test suite, in the directory, run `make all`, then run the test executable, `./bin/DataBlockTest`.\n\n## Mechanics\n\nDataBlock is based around a model of a two-way linked list, except every node also functions as a buffer itself. The blocks are singly allocated sections of data which had a header portion, that includes the previous block, next block, the capacity, and the length, and the body, which contains the actual binary data.\n\nThe `DataBlock` structure is implemented like this.\n\n```c\n\nstruct DataBlock\n{\n        struct DataBlock* next;\n        struct DataBlock* prev;\n        size_t cap;\n        size_t len;\n        unsigned char data[0];\n};\n```\n\nThe entire block is allocated into a single block of memory. This allows it to be variably sized.\nAdditionally, blocks can be written into one another, such as with the function `DataBlock_put_block()`.\n\n### Structure\n\nDataBlock's can be linked together in a chain, to form a stream-like data structure. DataBlock's can be used to implement a dynamic stream of data, that can be easily cut or expanded when needed.\n\nFor example, the `DataBlock_print_debug()` method prints out something like this.\n\n```\n___Block_1_______\nHeader::\n@self = 0x7ff3aac02660\n@next = 0x7ff3aac02690\n@prev = 0x0\n@length = 5\n@capacity = 10\nBody::\n(0.) -\u003e 5\n(1.) -\u003e 5\n(2.) -\u003e 5\n(3.) -\u003e 5\n(4.) -\u003e 5\n___Block_1_end___\n___Block_2_______\nHeader::\n@self = 0x7ff3aac02690\n@next = 0x7ff3aac026c0\n@prev = 0x7ff3aac02660\n@length = 10\n@capacity = 15\nBody::\n(0.) -\u003e 66\n(1.) -\u003e 66\n(2.) -\u003e 66\n(3.) -\u003e 66\n(4.) -\u003e 66\n(5.) -\u003e 66\n(6.) -\u003e 66\n(7.) -\u003e 66\n(8.) -\u003e 66\n(9.) -\u003e 66\n___Block_2_end___\n___Block_3_______\nHeader::\n@self = 0x7ff3aac026c0\n@next = 0x0\n@prev = 0x7ff3aac02690\n@length = 10\n@capacity = 15\nBody::\n(0.) -\u003e 66\n(1.) -\u003e 66\n(2.) -\u003e 66\n(3.) -\u003e 66\n(4.) -\u003e 66\n(5.) -\u003e 66\n(6.) -\u003e 66\n(7.) -\u003e 66\n(8.) -\u003e 66\n(9.) -\u003e 66\n___Block_3_end___\n```\n\nThe `header` of each DataBlock contains info about the block, its next and previous sister blocks, its length, and it's capacity.\n\nThe `len` property of each block can be reset to zero, allowing the existing data to be overwritten, which can conserve space.\n\n\n## License\n\n`DataBlock` is licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjweinst1%2Fdatablock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjweinst1%2Fdatablock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjweinst1%2Fdatablock/lists"}