Skip to content

Data Structure: Dynamic Array - #841

Merged
bradh352 merged 12 commits into
c-ares:mainfrom
bradh352:array
Aug 1, 2024
Merged

Data Structure: Dynamic Array#841
bradh352 merged 12 commits into
c-ares:mainfrom
bradh352:array

Conversation

@bradh352

@bradh352 bradh352 commented Jul 31, 2024

Copy link
Copy Markdown
Member

Create a new data structure for a basic growable indexable array, supporting the features you'd normally expect such as insert (at, last, first), remove (at, last, first), and get (at, last, first). Internally all data is stored in an appropriately sized array that can directly be returned to the caller as a C array of the data type provided. The array grows by powers of two, and has optimizations for head and tail removals.

Array modifications can be risky (e.g. wrong reallocation sizes, mis-sized memory moves, out-of-bounds access), so it makes sense to have standardized code that is well tested.

The arrays used by the dns record parser / writer have been converted to the new array data structure as have a few other instances.

Authored-By: Brad House (@bradh352)

@bradh352
bradh352 merged commit 0e4b735 into c-ares:main Aug 1, 2024
@bradh352
bradh352 deleted the array branch August 1, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant