aboutsummaryrefslogtreecommitdiff
path: root/src/big_int.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-07-14 23:36:23 +0100
committergingerBill <bill@gingerbill.org>2021-07-14 23:36:23 +0100
commit10f4d8df32f73e3c5071a6e168a0923a53d8332f (patch)
tree8d8185c9f6a9764526cb117a70581d362b1920a9 /src/big_int.cpp
parente15858e2be223c52e4daaf433d62ee5719943782 (diff)
Override libtommath allocation procedures
Diffstat (limited to 'src/big_int.cpp')
-rw-r--r--src/big_int.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/big_int.cpp b/src/big_int.cpp
index 6386b1d6f..20f940e8e 100644
--- a/src/big_int.cpp
+++ b/src/big_int.cpp
@@ -1,5 +1,36 @@
#include "libtommath/tommath.h"
+#if 0
+void *MP_MALLOC(size_t size) {
+ return malloc(size);
+}
+void *MP_REALLOC(void *mem, size_t oldsize, size_t newsize) {
+ return realloc(mem, newsize);
+}
+void *MP_CALLOC(size_t nmemb, size_t size) {
+ return calloc(nmemb, size);
+}
+void MP_FREE(void *mem, size_t size) {
+ free(mem);
+}
+#else
+
+void *MP_MALLOC(size_t size) {
+ return gb_alloc(permanent_allocator(), cast(isize)size);
+}
+void *MP_REALLOC(void *mem, size_t oldsize, size_t newsize) {
+ return gb_resize(permanent_allocator(), mem, cast(isize)oldsize, cast(isize)newsize);
+}
+void *MP_CALLOC(size_t nmemb, size_t size) {
+ size_t total = nmemb*size;
+ return gb_alloc(permanent_allocator(), cast(isize)total);
+}
+void MP_FREE(void *mem, size_t size) {
+ // DO NOTHING
+}
+#endif
+
+
#ifndef MAX_BIG_INT_SHIFT
#define MAX_BIG_INT_SHIFT 1024
#endif