diff options
author | Yann Collet <cyan@fb.com> | 2022-07-01 08:36:32 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2022-07-01 08:36:32 (GMT) |
commit | 35565bf0dc118c8825c437ec320572b6c78a2a3e (patch) | |
tree | 1a20426c2ba4885c78aa48c39227f1d90f98e1d7 /programs/util.h | |
parent | 24b50935f9d56bb82214961dbcbd83f8c296b44b (diff) | |
download | lz4-35565bf0dc118c8825c437ec320572b6c78a2a3e.zip lz4-35565bf0dc118c8825c437ec320572b6c78a2a3e.tar.gz lz4-35565bf0dc118c8825c437ec320572b6c78a2a3e.tar.bz2 |
refactored logic to test special file names
Diffstat (limited to 'programs/util.h')
-rw-r--r-- | programs/util.h | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/programs/util.h b/programs/util.h index 2840179..99bcca9 100644 --- a/programs/util.h +++ b/programs/util.h @@ -175,6 +175,39 @@ extern "C" { #endif + +/*-**************************************** +* Allocation functions +******************************************/ +/* + * A modified version of realloc(). + * If UTIL_realloc() fails the original block is freed. +*/ +UTIL_STATIC void* UTIL_realloc(void* ptr, size_t size) +{ + void* const newptr = realloc(ptr, size); + if (newptr) return newptr; + free(ptr); + return NULL; +} + + +/*-**************************************** +* String functions +******************************************/ +/* + * A modified version of realloc(). + * If UTIL_realloc() fails the original block is freed. +*/ +UTIL_STATIC int UTIL_sameString(const char* a, const char* b) +{ + assert(a!=NULL && b!=NULL); /* unsupported scenario */ + if (a==NULL) return 0; + if (b==NULL) return 0; + return !strcmp(a,b); +} + + /*-**************************************** * Time functions ******************************************/ @@ -451,19 +484,6 @@ UTIL_STATIC U64 UTIL_getTotalFileSize(const char** fileNamesTable, unsigned nbFi } -/* - * A modified version of realloc(). - * If UTIL_realloc() fails the original block is freed. -*/ -UTIL_STATIC void* UTIL_realloc(void* ptr, size_t size) -{ - void* const newptr = realloc(ptr, size); - if (newptr) return newptr; - free(ptr); - return NULL; -} - - #ifdef _WIN32 # define UTIL_HAS_CREATEFILELIST |