Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/util.h
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | static SECP256K1_INLINE void *manual_alloc(void** prealloc_ptr, size_t alloc_size, void* base, size_t max_size) { | ||||
void* ret; | void* ret; | ||||
VERIFY_CHECK(prealloc_ptr != NULL); | VERIFY_CHECK(prealloc_ptr != NULL); | ||||
VERIFY_CHECK(*prealloc_ptr != NULL); | VERIFY_CHECK(*prealloc_ptr != NULL); | ||||
VERIFY_CHECK(base != NULL); | VERIFY_CHECK(base != NULL); | ||||
VERIFY_CHECK((unsigned char*)*prealloc_ptr >= (unsigned char*)base); | VERIFY_CHECK((unsigned char*)*prealloc_ptr >= (unsigned char*)base); | ||||
VERIFY_CHECK(((unsigned char*)*prealloc_ptr - (unsigned char*)base) % ALIGNMENT == 0); | VERIFY_CHECK(((unsigned char*)*prealloc_ptr - (unsigned char*)base) % ALIGNMENT == 0); | ||||
VERIFY_CHECK((unsigned char*)*prealloc_ptr - (unsigned char*)base + aligned_alloc_size <= max_size); | VERIFY_CHECK((unsigned char*)*prealloc_ptr - (unsigned char*)base + aligned_alloc_size <= max_size); | ||||
ret = *prealloc_ptr; | ret = *prealloc_ptr; | ||||
*((unsigned char**)prealloc_ptr) += aligned_alloc_size; | *prealloc_ptr = (unsigned char*)*prealloc_ptr + aligned_alloc_size; | ||||
return ret; | return ret; | ||||
} | } | ||||
/* Macro for restrict, when available and not in a VERIFY build. */ | /* Macro for restrict, when available and not in a VERIFY build. */ | ||||
#if defined(SECP256K1_BUILD) && defined(VERIFY) | #if defined(SECP256K1_BUILD) && defined(VERIFY) | ||||
# define SECP256K1_RESTRICT | # define SECP256K1_RESTRICT | ||||
#else | #else | ||||
# if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) | # if (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ) | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |