Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crc helpers for writing to large buffers. #93

Merged
merged 9 commits into from
Sep 6, 2024
Merged

Conversation

DmitriyMusatkin
Copy link
Contributor

Issue #, if available:

Description of changes:
we defined all crc functions to take int for length and then in every binding we have code to work around buffers that are more than INT_MAX.
This just add same helper here so we can skip repeating it in every binding.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@DmitriyMusatkin DmitriyMusatkin changed the title Add crc helper for writing to large buffers. Add crc helpers for writing to large buffers. Sep 5, 2024
include/aws/checksums/crc.h Outdated Show resolved Hide resolved
include/aws/checksums/crc.h Outdated Show resolved Hide resolved
#include <limits.h>

#define large_buffer_apply_impl(Name, T) \
T aws_large_buffer_apply_##Name( \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
T aws_large_buffer_apply_##Name( \
static T aws_large_buffer_apply_##Name( \

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or don't declare a separate function here, just have it be the implementation like:

#define CHECKSUM_WITH_SIZE_IMPL(Name, T) \
   ...                                   \
   return val

and then

uint32_t aws_checksums_crc32_with_size(const uint8_t *input, size_t length, uint32_t previous_crc32) {
    CHECKSUM_WITH_SIZE_IMPL(aws_checksums_crc32, uint32_t);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer to keep a separate function here, mostly to sanity check that function pointer prototype has args that match the other args passed to this function.

@DmitriyMusatkin DmitriyMusatkin merged commit e5c9b16 into main Sep 6, 2024
39 checks passed
@DmitriyMusatkin DmitriyMusatkin deleted the u64_len branch September 6, 2024 15:15
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.

2 participants