summaryrefslogtreecommitdiff
path: root/gmp-glue.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2013-12-15 19:13:37 +0100
committerNiels Möller <nisse@lysator.liu.se>2013-12-15 19:14:18 +0100
commit53bcd6b4118c0cd9f2a95debc5897da9a3bb1381 (patch)
tree293e181213c439f46ceb7b569cfe300d347b2dc1 /gmp-glue.c
parent6c0f9c0fa041efccfab4f5ec6603afffa8f6dd8e (diff)
downloadnettle-53bcd6b4118c0cd9f2a95debc5897da9a3bb1381.tar.gz
Define and use new TMP_GMP_ALLOC macro.
Diffstat (limited to 'gmp-glue.c')
-rw-r--r--gmp-glue.c25
1 files changed, 24 insertions, 1 deletions
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);
+}