summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakayuki Matsuoka <t-mat@users.noreply.github.com>2022-08-07 10:06:37 (GMT)
committerTakayuki Matsuoka <t-mat@users.noreply.github.com>2022-08-07 10:06:37 (GMT)
commit721e76d1af1d248d0e6fefb2a090cd4b1c4a08f2 (patch)
treea9d54c2b8b30d491c7d821ab5aa297fa6e81688c
parentca26930a91e5b1d47d725b1043e1f5282fd18aaf (diff)
downloadlz4-721e76d1af1d248d0e6fefb2a090cd4b1c4a08f2.zip
lz4-721e76d1af1d248d0e6fefb2a090cd4b1c4a08f2.tar.gz
lz4-721e76d1af1d248d0e6fefb2a090cd4b1c4a08f2.tar.bz2
Add LZ4_FREESTANDING
-rw-r--r--lib/lz4.c4
-rw-r--r--lib/lz4.h23
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/lz4.c b/lib/lz4.c
index 5fae002..ad12281 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -209,7 +209,9 @@ void LZ4_free(void* p);
# define FREEMEM(p) free(p)
#endif
-#include <string.h> /* memset, memcpy */
+#if ! LZ4_FREESTANDING
+# include <string.h> /* memset, memcpy */
+#endif
#if !defined(LZ4_memset)
# define LZ4_memset(p,v,s) memset((p),(v),(s))
#endif
diff --git a/lib/lz4.h b/lib/lz4.h
index fee8890..01ab445 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -97,6 +97,29 @@ extern "C" {
# define LZ4LIB_API LZ4LIB_VISIBILITY
#endif
+/*!
+ * LZ4_FREESTANDING :
+ * Enable "freestanding mode" that is suitable for typical freestanding environment.
+ * In freestanding mode, some LZ4/HC functions which use heap are disabled.
+ */
+#if defined(LZ4_FREESTANDING) && (LZ4_FREESTANDING == 1)
+# define LZ4_HEAPMODE 0
+# define LZ4HC_HEAPMODE 0
+# define LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION 1
+# if !defined(LZ4_memcpy)
+# error "LZ4_FREESTANDING requires macro 'LZ4_memcpy'."
+# endif
+# if !defined(LZ4_memset)
+# error "LZ4_FREESTANDING requires macro 'LZ4_memset'."
+# endif
+# if !defined(LZ4_memmove)
+# error "LZ4_FREESTANDING requires macro 'LZ4_memmove'."
+# endif
+#elif ! defined(LZ4_FREESTANDING)
+# define LZ4_FREESTANDING 0
+#endif
+
+
/*------ Version ------*/
#define LZ4_VERSION_MAJOR 1 /* for breaking interface changes */
#define LZ4_VERSION_MINOR 9 /* for new (non-breaking) interface capabilities */