summaryrefslogtreecommitdiffstats
path: root/programs/util.h
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2022-07-01 08:36:32 (GMT)
committerYann Collet <cyan@fb.com>2022-07-01 08:36:32 (GMT)
commit35565bf0dc118c8825c437ec320572b6c78a2a3e (patch)
tree1a20426c2ba4885c78aa48c39227f1d90f98e1d7 /programs/util.h
parent24b50935f9d56bb82214961dbcbd83f8c296b44b (diff)
downloadlz4-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.h46
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