Skip to content

Commit

Permalink
fixup! Determine ALIGNMENT more cleverly and move it to util.h
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Oct 25, 2018
1 parent 1572a22 commit 13fff2c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ static SECP256K1_INLINE void *checked_realloc(const secp256k1_callback* cb, void
static SECP256K1_INLINE void *manual_alloc(void** prealloc_ptr, size_t alloc_size, void* base, size_t max_size) {
size_t aligned_alloc_size = ROUND_TO_ALIGN(alloc_size);
void* ret = *prealloc_ptr;
CHECK((char*)*prealloc_ptr != NULL);
CHECK((char*)*prealloc_ptr >= (char*)base);
CHECK(((char*)*prealloc_ptr - (char*)base) + aligned_alloc_size <= max_size);
*((char**)prealloc_ptr) += aligned_alloc_size;
CHECK((unsigned char*)*prealloc_ptr != NULL);
CHECK((unsigned char*)*prealloc_ptr >= (unsigned char*)base);
CHECK(((unsigned char*)*prealloc_ptr - (unsigned char*)base) + aligned_alloc_size <= max_size);
*((unsigned char**)prealloc_ptr) += aligned_alloc_size;
return ret;
}

Expand Down

0 comments on commit 13fff2c

Please sign in to comment.