Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/util.h
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
#elif defined(VERIFY) | #elif defined(VERIFY) | ||||
#define VERIFY_CHECK CHECK | #define VERIFY_CHECK CHECK | ||||
#define VERIFY_SETUP(stmt) do { stmt; } while(0) | #define VERIFY_SETUP(stmt) do { stmt; } while(0) | ||||
#else | #else | ||||
#define VERIFY_CHECK(cond) do { (void)(cond); } while(0) | #define VERIFY_CHECK(cond) do { (void)(cond); } while(0) | ||||
#define VERIFY_SETUP(stmt) | #define VERIFY_SETUP(stmt) | ||||
#endif | #endif | ||||
/* Define `VG_UNDEF` and `VG_CHECK` when VALGRIND is defined */ | |||||
#if !defined(VG_CHECK) | |||||
# if defined(VALGRIND) | |||||
# include <valgrind/memcheck.h> | |||||
# define VG_UNDEF(x,y) VALGRIND_MAKE_MEM_UNDEFINED((x),(y)) | |||||
# define VG_CHECK(x,y) VALGRIND_CHECK_MEM_IS_DEFINED((x),(y)) | |||||
# else | |||||
# define VG_UNDEF(x,y) | |||||
# define VG_CHECK(x,y) | |||||
# endif | |||||
#endif | |||||
/* Like `VG_CHECK` but on VERIFY only */ | |||||
#if defined(VERIFY) | |||||
#define VG_CHECK_VERIFY(x,y) VG_CHECK((x), (y)) | |||||
#else | |||||
#define VG_CHECK_VERIFY(x,y) | |||||
#endif | |||||
static SECP256K1_INLINE void *checked_malloc(const secp256k1_callback* cb, size_t size) { | static SECP256K1_INLINE void *checked_malloc(const secp256k1_callback* cb, size_t size) { | ||||
void *ret = malloc(size); | void *ret = malloc(size); | ||||
if (ret == NULL) { | if (ret == NULL) { | ||||
secp256k1_callback_call(cb, "Out of memory"); | secp256k1_callback_call(cb, "Out of memory"); | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |