aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/utils/compiler.h11
-rw-r--r--src/lib/utils/mem_ops.h2
2 files changed, 12 insertions, 1 deletions
diff --git a/src/lib/utils/compiler.h b/src/lib/utils/compiler.h
index 00f22358a..9ef0f75b3 100644
--- a/src/lib/utils/compiler.h
+++ b/src/lib/utils/compiler.h
@@ -85,6 +85,17 @@
#endif
/*
+* Define BOTAN_MALLOC_FN
+*/
+#if defined(__GNUG__) || defined(__clang__)
+ #define BOTAN_MALLOC_FN __attribute__ ((malloc))
+#elif defined(_MSC_VER)
+ #define BOTAN_MALLOC_FN __declspec(restrict)
+#else
+ #define BOTAN_MALLOC_FN
+#endif
+
+/*
* Define BOTAN_DEPRECATED
*/
#if !defined(BOTAN_NO_DEPRECATED_WARNINGS)
diff --git a/src/lib/utils/mem_ops.h b/src/lib/utils/mem_ops.h
index 4b03b23d2..3274bfaf6 100644
--- a/src/lib/utils/mem_ops.h
+++ b/src/lib/utils/mem_ops.h
@@ -22,7 +22,7 @@ namespace Botan {
* @param elem_size the size of each element
* @return pointer to allocated and zeroed memory, or throw std::bad_alloc on failure
*/
-BOTAN_PUBLIC_API(2,3) void* allocate_memory(size_t elems, size_t elem_size);
+BOTAN_PUBLIC_API(2,3) BOTAN_MALLOC_FN void* allocate_memory(size_t elems, size_t elem_size);
/**
* Free a pointer returned by allocate_memory