diff options
| author | @syxhe <https://t.me/syxhe> | 2025-03-28 17:23:55 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-03-28 17:23:55 -0500 |
| commit | 97713275dc87ea1d0afa4fd6bc49f695ad40efc0 (patch) | |
| tree | 3bd1d8c14639808a66b3a5b6e7a27f6a7261cce5 /src/shared.h | |
| parent | cfdd25cdd8efabaa43446036e0ff0c326c001f8f (diff) | |
Create xalloc function and wrappers, fix XALLOC_EXIT usages to comply with ISO C99
Diffstat (limited to 'src/shared.h')
| -rw-r--r-- | src/shared.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/shared.h b/src/shared.h index b9e7bcd..718bbf2 100644 --- a/src/shared.h +++ b/src/shared.h | |||
| @@ -29,10 +29,13 @@ | |||
| 29 | exit(EXIT_FAILURE); /* Makes gcc happy */\ | 29 | exit(EXIT_FAILURE); /* Makes gcc happy */\ |
| 30 | } while (0) | 30 | } while (0) |
| 31 | 31 | ||
| 32 | // `calloc()` with error checking. Calls `error()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | 32 | // `malloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` |
| 33 | void * xmalloc(size_t size); | ||
| 34 | |||
| 35 | // `calloc()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | ||
| 33 | void* xcalloc(size_t nmemb, size_t size); | 36 | void* xcalloc(size_t nmemb, size_t size); |
| 34 | 37 | ||
| 35 | // `reallocarray()` with error checking. Calls `error()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` | 38 | // `reallocarray()` with error checking. Calls `exit()` or `abort()` on error, depending on the value of `___VXGG___XALLOC_EXIT_ON_ERROR___` |
| 36 | void* xreallocarray(void *ptr, size_t nmemb, size_t size); | 39 | void* xreallocarray(void *ptr, size_t nmemb, size_t size); |
| 37 | 40 | ||
| 38 | // Read the entire contents of a file descriptor into a malloc()'ed buffer | 41 | // Read the entire contents of a file descriptor into a malloc()'ed buffer |
