aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJ08nY2017-05-29 15:11:38 +0200
committerJ08nY2017-05-29 15:11:38 +0200
commitba8c1f2bc424205cbb167b3c65ce184912c6173a (patch)
treedb21c80b3e7ed411ddbdc4151f82b875b83f279e /src/util
parent03eedf3f3e69093af6fd2717bbad04ffdfc7c25a (diff)
downloadecgen-ba8c1f2bc424205cbb167b3c65ce184912c6173a.tar.gz
ecgen-ba8c1f2bc424205cbb167b3c65ce184912c6173a.tar.zst
ecgen-ba8c1f2bc424205cbb167b3c65ce184912c6173a.zip
Add some more comments and docs, move exhaustive/seed.[ch] into math/
Diffstat (limited to 'src/util')
-rw-r--r--src/util/macro.h14
-rw-r--r--src/util/memory.c4
-rw-r--r--src/util/memory.h6
3 files changed, 5 insertions, 19 deletions
diff --git a/src/util/macro.h b/src/util/macro.h
deleted file mode 100644
index abe2c5f..0000000
--- a/src/util/macro.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * ecgen, tool for generating Elliptic curve domain parameters
- * Copyright (C) 2017 J08nY
- */
-/**
- * @file macro.h
- */
-#ifndef ECGEN_MACRO_H
-#define ECGEN_MACRO_H
-
-#define VA_NARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
-#define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)
-
-#endif // ECGEN_MACRO_H
diff --git a/src/util/memory.c b/src/util/memory.c
index 9724c81..2c2281c 100644
--- a/src/util/memory.c
+++ b/src/util/memory.c
@@ -9,7 +9,7 @@ void *alloc(void *(*fun)(size_t), size_t size) {
void *result = fun(size);
if (!result) {
perror("Couldn't alloc.");
- exit(1);
+ exit(EXIT_FAILURE);
}
return result;
}
@@ -22,7 +22,7 @@ void *try_realloc(void *ptr, size_t size) {
void *result = pari_realloc(ptr, size);
if (!result) {
perror("Couldn't alloc.");
- exit(1);
+ exit(EXIT_FAILURE);
}
return result;
} \ No newline at end of file
diff --git a/src/util/memory.h b/src/util/memory.h
index 8b85a3d..55e8eac 100644
--- a/src/util/memory.h
+++ b/src/util/memory.h
@@ -11,21 +11,21 @@
#include <stddef.h>
/**
- * @brief
+ * @brief Try mallocing some memory, exit(EXIT_FAILURE) if it fails.
* @param size
* @return
*/
void *try_malloc(size_t size);
/**
- * @brief
+ * @brief Try callocing some memory, exit(EXIT_FAILURE) if it fails.
* @param size
* @return
*/
void *try_calloc(size_t size);
/**
- * @brief
+ * @brief Try reallocing some memory, exit(EXIT_FAILURE) if it fails.
* @param ptr
* @param size
* @return