format block macros
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/tommath_private.h b/tommath_private.h
index 2fa3e0e..b316358 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -33,17 +33,53 @@ extern "C" {
# define MP_FREE_BUFFER(mem, size) MP_FREE((mem), (size))
# define MP_FREE_DIGITS(mem, digits) MP_FREE((mem), sizeof (mp_digit) * (digits))
#else
-# define MP_FREE_BUFFER(mem, size) do { size_t fs_ = (size); void* fm_ = (mem); if (fm_) { MP_ZERO_BUFFER(fm_, fs_); MP_FREE(fm_, fs_); } } while (0)
-# define MP_FREE_DIGITS(mem, digits) do { int fd_ = (digits); void* fm_ = (mem); if (fm_) { MP_ZERO_BUFFER(fm_, sizeof (mp_digit) * (size_t)fd_); MP_FREE(fm_, sizeof (mp_digit) * (size_t)fd_); } } while (0)
+# define MP_FREE_BUFFER(mem, size) \
+do { \
+ size_t fs_ = (size); \
+ void* fm_ = (mem); \
+ if (fm_) { \
+ MP_ZERO_BUFFER(fm_, fs_); \
+ MP_FREE(fm_, fs_); \
+ } \
+} while (0)
+# define MP_FREE_DIGITS(mem, digits) \
+do { \
+ int fd_ = (digits); \
+ void* fm_ = (mem); \
+ if (fm_) { \
+ MP_ZERO_BUFFER(fm_, sizeof(mp_digit) * (size_t)fd_); \
+ MP_FREE(fm_, sizeof(mp_digit) * (size_t)fd_); \
+ } \
+} while (0)
#endif
#ifdef MP_USE_MEMSET
# include <string.h>
# define MP_ZERO_BUFFER(mem, size) memset((mem), 0, (size))
-# define MP_ZERO_DIGITS(mem, digits) do { int zd_ = (digits); if (zd_ > 0) { memset((mem), 0, sizeof (mp_digit) * (size_t)zd_); } } while (0)
+# define MP_ZERO_DIGITS(mem, digits) \
+do { \
+ int zd_ = (digits); \
+ if (zd_ > 0) { \
+ memset((mem), 0, sizeof(mp_digit) * (size_t)zd_); \
+ } \
+} while (0)
#else
-# define MP_ZERO_BUFFER(mem, size) do { size_t zs_ = (size); char* zm_ = (char*)(mem); while (zs_-- > 0) { *zm_++ = 0; } } while (0)
-# define MP_ZERO_DIGITS(mem, digits) do { int zd_ = (digits); mp_digit* zm_ = (mem); while (zd_-- > 0) { *zm_++ = 0; } } while (0)
+# define MP_ZERO_BUFFER(mem, size) \
+do { \
+ size_t zs_ = (size); \
+ char* zm_ = (char*)(mem); \
+ while (zs_-- > 0) { \
+ *zm_++ = 0; \
+ } \
+} while (0)
+# define MP_ZERO_DIGITS(mem, digits) \
+do { \
+ int zd_ = (digits); \
+ mp_digit* zm_ = (mem); \
+ while (zd_-- > 0) { \
+ *zm_++ = 0; \
+ } \
+} while (0)
#endif
/* Tunable cutoffs