diff options
| author | @syxhe <https://t.me/syxhe> | 2024-12-26 21:42:53 -0600 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2024-12-26 21:42:53 -0600 |
| commit | 03c5fce0220d3e5d02d320f925a3b9401a397729 (patch) | |
| tree | db27acac8fceee17cace9fa05ddd24fa6fe23cf9 /src/shared.c | |
| parent | f7ded3958a7f3bea16e2c8be55f159f34a45ca61 (diff) | |
Put some notes down
Diffstat (limited to 'src/shared.c')
| -rw-r--r-- | src/shared.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/shared.c b/src/shared.c new file mode 100644 index 0000000..5e58de0 --- /dev/null +++ b/src/shared.c | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #include "shared.h" | ||
| 2 | |||
| 3 | #include <stdlib.h> | ||
| 4 | #include <errno.h> | ||
| 5 | #include <error.h> | ||
| 6 | |||
| 7 | void* xcalloc(size_t nmemb, size_t size) { | ||
| 8 | void *mem = calloc(nmemb, size); | ||
| 9 | |||
| 10 | if(mem == NULL) { | ||
| 11 | #if defined ___VXGG___XCALLOC_EXIT_ON_ERROR___ && ___VXGG___XCALLOC_EXIT_ON_ERROR___ > 0 | ||
| 12 | error(1, errno, "<xcalloc> Could not allocate memory"); | ||
| 13 | #endif | ||
| 14 | |||
| 15 | abort(); | ||
| 16 | } | ||
| 17 | |||
| 18 | |||
| 19 | return mem; | ||
| 20 | } \ No newline at end of file | ||
