Override libtommath allocation procedures

This commit is contained in:
gingerBill
2021-07-14 23:36:23 +01:00
parent e15858e2be
commit 10f4d8df32
4 changed files with 59 additions and 27 deletions
+31
View File
@@ -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