From 53bcd6b4118c0cd9f2a95debc5897da9a3bb1381 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sun, 15 Dec 2013 19:13:37 +0100 Subject: Define and use new TMP_GMP_ALLOC macro. --- gmp-glue.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'gmp-glue.c') diff --git a/gmp-glue.c b/gmp-glue.c index a2633a50..f76c3411 100644 --- a/gmp-glue.c +++ b/gmp-glue.c @@ -3,7 +3,8 @@ /* nettle, low-level cryptographics library * * Copyright (C) 2013 Niels Möller - * + * Copyright (C) 2013 Red Hat + * * The nettle library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at your @@ -239,3 +240,25 @@ gmp_free_limbs (mp_limb_t *p, mp_size_t n) free_func (p, (size_t) n * sizeof(mp_limb_t)); } + +void * +gmp_alloc(size_t n) +{ + void *(*alloc_func)(size_t); + assert (n > 0); + + mp_get_memory_functions(&alloc_func, NULL, NULL); + + return alloc_func (n); +} + +void +gmp_free(void *p, size_t n) +{ + void (*free_func)(void *, size_t); + assert (n > 0); + assert (p != 0); + mp_get_memory_functions (NULL, NULL, &free_func); + + free_func (p, (size_t) n); +} -- cgit v1.2.1