diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-05-14 00:23:52 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-05-14 00:23:52 +0200 |
| commit | 9e524b9dedeeea7f5d5e39edb80c588b161deed4 (patch) | |
| tree | 9e497cf96ea22611014592229ee1baab94029b42 /src/util | |
| parent | Add blind-kernel (diff) | |
| download | blind-9e524b9dedeeea7f5d5e39edb80c588b161deed4.tar.gz blind-9e524b9dedeeea7f5d5e39edb80c588b161deed4.tar.bz2 blind-9e524b9dedeeea7f5d5e39edb80c588b161deed4.tar.xz | |
Add gaussian blur and unshaping kernels
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
| -rw-r--r-- | src/util/emalloc.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util/emalloc.h b/src/util/emalloc.h index 214a773..39efcea 100644 --- a/src/util/emalloc.h +++ b/src/util/emalloc.h @@ -4,12 +4,14 @@ #define emalloc(...) enmalloc(1, __VA_ARGS__) #define emalloc2(...) enmalloc2(1, __VA_ARGS__) +#define emalloc3(...) enmalloc3(1, __VA_ARGS__) #define ecalloc(...) encalloc(1, __VA_ARGS__) #define erealloc(...) enrealloc(1, __VA_ARGS__) #define erealloc2(...) enrealloc2(1, __VA_ARGS__) #define erealloc3(...) enrealloc3(1, __VA_ARGS__) #define malloc2(n, m) malloc(n * m); +#define malloc3(n1, n2, n3) malloc(n1 * n2 * n3); #define realloc2(p, n, m) realloc(p, n * m); #define realloc3(p, n1, n2, n3) realloc(p, n1 * n2 * n3); @@ -32,6 +34,18 @@ enmalloc2(int status, size_t n, size_t m) } static inline void * +enmalloc3(int status, size_t n1, size_t n2, size_t n3) +{ + void *ptr; + size_t n = n1; + if (n2 > SIZE_MAX / n || + n3 > SIZE_MAX / (n *= n2) || + !(ptr = malloc(n * n3))) + enprintf(status, "malloc: out of memory\n"); + return ptr; +} + +static inline void * encalloc(int status, size_t n, size_t m) { void *ptr = calloc(n, m); |
