Skip to content

Commit

Permalink
funk-alloc-fix: change alloc alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
asiegel-jt committed Apr 26, 2024
1 parent 5af9e4f commit fcefa97
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/funk/fd_funk_val.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fd_funk_val_copy( fd_funk_rec_t * rec,
such that if it fails, we haven't affected the state. */

ulong new_val_max;
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 1UL, sz_est, &new_val_max );
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 8UL, sz_est, &new_val_max );

if( FD_UNLIKELY( !new_val ) ) { /* Fallback on in-place */

Expand Down Expand Up @@ -135,13 +135,13 @@ fd_funk_val_append( fd_funk_rec_t * rec,

if( FD_UNLIKELY( new_val_sz > val_max ) ) {

ulong new_val_max = fd_ulong_min( fd_alloc_max_expand( val_max, 1UL, new_val_sz ), FD_FUNK_REC_VAL_MAX );
ulong new_val_max = fd_ulong_min( fd_alloc_max_expand( val_max, 8UL, new_val_sz ), FD_FUNK_REC_VAL_MAX );
if( FD_UNLIKELY( new_val_max<=val_max ) ) { /* Already expanded as much as possible */
fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_INVAL );
return NULL;
}

uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 1UL, new_val_max, &new_val_max );
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 8UL, new_val_max, &new_val_max );
if( FD_UNLIKELY( !new_val ) ) { /* Allocation failure */
fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_MEM );
return NULL;
Expand Down Expand Up @@ -205,7 +205,7 @@ fd_funk_val_truncate( fd_funk_rec_t * rec,
uchar * val = val_max ? fd_wksp_laddr_fast( wksp, val_gaddr ) : NULL; /* TODO: branchless */

ulong new_val_max;
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 1UL, new_val_sz, &new_val_max );
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 8UL, new_val_sz, &new_val_max );
if( FD_UNLIKELY( !new_val ) ) { /* Allocation failure! */
fd_int_store_if( !!opt_err, opt_err, FD_FUNK_ERR_MEM );
return NULL;
Expand Down Expand Up @@ -234,7 +234,7 @@ fd_funk_val_truncate( fd_funk_rec_t * rec,
uchar * val = (uchar *)fd_wksp_laddr_fast( wksp, rec->val_gaddr );

ulong new_val_max;
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 1UL, new_val_sz, &new_val_max );
uchar * new_val = (uchar *)fd_alloc_malloc_at_least( alloc, 8UL, new_val_sz, &new_val_max );

if( FD_UNLIKELY( !new_val ) ) { /* Fallback on in-place */

Expand Down Expand Up @@ -271,7 +271,7 @@ fd_funk_val_safe( fd_funk_rec_t const * rec, /* Assumes pointer in caller's
uint val_sz = rec->val_sz;
*result_len = val_sz;
if( !val_sz ) return NULL;
void * res = fd_valloc_malloc( valloc, 1U, val_sz );
void * res = fd_valloc_malloc( valloc, 8U, val_sz );
/* Note that this memcpy may copy recently freed memory, but it
won't crash, which is the important thing */
fd_memcpy( res, fd_wksp_laddr_fast( wksp, rec->val_gaddr ), val_sz );
Expand Down

0 comments on commit fcefa97

Please sign in to comment.