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

Avoid discarding const. #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions verstable.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static inline size_t vt_quadratic( uint16_t displacement )
static inline int vt_first_nonzero_uint16( uint64_t val )
{
const uint16_t endian_checker = 0x0001;
if( *(char *)&endian_checker ) // Little-endian (the compiler will optimize away the check at -O1 and above).
if( *(const char *)&endian_checker ) // Little-endian (the compiler will optimize away the check at -O1 and above).
return __builtin_ctzll( val ) / 16;

return __builtin_clzll( val ) / 16;
Expand Down Expand Up @@ -519,7 +519,7 @@ static inline int vt_first_nonzero_uint16( uint64_t val )

// When the bucket count is zero, setting the metadata pointer to point to a VT_EMPTY placeholder, rather than NULL,
// allows us to avoid checking for a zero bucket count during insertion and lookup.
static const uint16_t vt_empty_placeholder_metadatum = VT_EMPTY;
static uint16_t vt_empty_placeholder_metadatum = VT_EMPTY;

// Default hash and comparison functions.

Expand Down Expand Up @@ -961,7 +961,7 @@ VT_API_FN_QUALIFIERS bool VT_CAT( NAME, _init_clone )(
return false;

table->buckets = (VT_CAT( NAME, _bucket ) *)allocation;
table->metadata = (uint16_t *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( table ) );
table->metadata = (void *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( table ) );
memcpy( allocation, source->buckets, VT_CAT( NAME, _total_alloc_size )( table ) );

return true;
Expand Down Expand Up @@ -1274,7 +1274,7 @@ bool VT_CAT( NAME, _rehash )( NAME *table, size_t bucket_count )
return false;

new_table.buckets = (VT_CAT( NAME, _bucket ) *)allocation;
new_table.metadata = (uint16_t *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( &new_table ) );
new_table.metadata = (void *)( (unsigned char *)allocation + VT_CAT( NAME, _metadata_offset )( &new_table ) );

memset( new_table.metadata, 0x00, ( bucket_count + 4 ) * sizeof( uint16_t ) );

Expand Down