diff options
author | Daniel Lange <DLange@git.local> | 2021-01-11 20:43:28 +0100 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2021-01-11 20:43:28 +0100 |
commit | 94123a215ba971baf4ad7e12cc479258ddb8600e (patch) | |
tree | 6f053d8e1ce754ab7104b7364be9754231ab84de /XUtils.c | |
parent | 50cb99f0acecb15992f3d5610c02676a6c94f2a4 (diff) | |
parent | c55320e9e2a8916e911bcd39ab37b79e3a7d03b2 (diff) | |
download | debian_htop-94123a215ba971baf4ad7e12cc479258ddb8600e.tar.gz debian_htop-94123a215ba971baf4ad7e12cc479258ddb8600e.tar.bz2 debian_htop-94123a215ba971baf4ad7e12cc479258ddb8600e.zip |
Update upstream source from tag 'upstream/3.0.5'
Update to upstream version '3.0.5'
with Debian dir 10922042e094a59dc72f9c39ddd4bfd59c7a302c
Diffstat (limited to 'XUtils.c')
-rw-r--r-- | XUtils.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -13,6 +13,7 @@ in the source distribution for its full text. #include <errno.h> #include <fcntl.h> #include <stdarg.h> +#include <stdint.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -36,9 +37,21 @@ void* xMalloc(size_t size) { return data; } +void* xMallocArray(size_t nmemb, size_t size) { + assert(nmemb > 0); + assert(size > 0); + if (SIZE_MAX / nmemb < size) { + fail(); + } + return xMalloc(nmemb * size); +} + void* xCalloc(size_t nmemb, size_t size) { assert(nmemb > 0); assert(size > 0); + if (SIZE_MAX / nmemb < size) { + fail(); + } void* data = calloc(nmemb, size); if (!data) { fail(); @@ -56,6 +69,15 @@ void* xRealloc(void* ptr, size_t size) { return data; } +void* xReallocArray(void* ptr, size_t nmemb, size_t size) { + assert(nmemb > 0); + assert(size > 0); + if (SIZE_MAX / nmemb < size) { + fail(); + } + return xRealloc(ptr, nmemb * size); +} + char* String_cat(const char* s1, const char* s2) { const size_t l1 = strlen(s1); const size_t l2 = strlen(s2); |