diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f3cb4a6ce101f..3198215074e2a 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -521,6 +521,21 @@ static int gmp_unserialize(zval *object, zend_class_entry *ce, const unsigned ch } /* }}} */ +static void *gmp_alloc(size_t size) +{ + return emalloc(size); +} + +static void *gmp_realloc(void *ptr, size_t old_size, size_t new_size) +{ + return erealloc(ptr, new_size); +} + +static void gmp_free(void *ptr, size_t size) +{ + efree_size(ptr, size); +} + /* {{{ ZEND_GINIT_FUNCTION */ static ZEND_GINIT_FUNCTION(gmp) { @@ -551,6 +566,8 @@ ZEND_MINIT_FUNCTION(gmp) register_gmp_symbols(module_number); + mp_set_memory_functions(gmp_alloc, gmp_realloc, gmp_free); + return SUCCESS; } /* }}} */