Commit dcd5b982 authored by Niels Möller's avatar Niels Möller
Browse files

(TMP_DECL, TMP_ALLOC): New macros. When alloca

is unavailable, they work by allocating a fix amount of stack and
imposing a hard limit on what can be allocated.

Rev: src/nettle/nettle-internal.h:1.4
parent d1573de9
......@@ -29,6 +29,29 @@
#include "nettle-meta.h"
/* Temporary allocation, for systems that don't support alloca. Note
* that the allocation requests should always be reasonably small, so
* that they can fit on the stack. For non-alloca systems, we use a
* fix maximum size, and abort if we ever need anything larger. */
# define TMP_DECL(name, type, max) \
type *name
# define TMP_ALLOC(name, size) \
(name = alloca(sizeof (*name) * size))
#else /* !HAVE_ALLOCA */
# define TMP_DECL(name, type, max) \
type name[max]
# define TMP_ALLOC(name, size) \
do { if (size > (sizeof(name) / sizeof(name[0]))) abort(); } while (0)
/* Arbitrary limits which apply to systems that don't have alloca */
/* Doesn't quite fit with the other algorithms, because of the weak
* keys. Weak keys are not reported, the functions will simply crash
* if you try to use a weak key. */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment