Merge pull request #1129 from t-mat/disable-memory-alloc-add-doc

Add document for LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION

GitOrigin-RevId: dee9f95fd9b65ee25858e8e602e3084cf4870b41
Change-Id: Iaa7ea5a4c58db2bf92ac542dc3152accd381b3f4
diff --git a/lib/lz4.c b/lib/lz4.c
index ad12281..e37adb1 100644
--- a/lib/lz4.c
+++ b/lib/lz4.c
@@ -188,6 +188,17 @@
 /*-************************************
 *  Memory routines
 **************************************/
+
+/*! LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION :
+ *  Disable relatively high-level LZ4/HC functions that use dynamic memory
+ *  allocation functions (malloc(), calloc(), free()).
+ *
+ *  Note that this is a compile-time switch. And since it disables
+ *  public/stable LZ4 v1 API functions, we don't recommend using this
+ *  symbol to generate a library for distribution.
+ *
+ *  The following functions are removed when this symbol is defined.
+ */
 #if defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
 #  define ALLOC(s)          lz4_error_memory_allocation_is_disabled
 #  define ALLOC_AND_ZERO(s) lz4_error_memory_allocation_is_disabled
diff --git a/lib/lz4.h b/lib/lz4.h
index 9d93eb1..c9a59e3 100644
--- a/lib/lz4.h
+++ b/lib/lz4.h
@@ -311,8 +311,10 @@
 ***********************************************/
 typedef union LZ4_stream_u LZ4_stream_t;  /* incomplete type (defined later) */
 
+#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
 LZ4LIB_API LZ4_stream_t* LZ4_createStream(void);
 LZ4LIB_API int           LZ4_freeStream (LZ4_stream_t* streamPtr);
+#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
 
 /*! LZ4_resetStream_fast() : v1.9.0+
  *  Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
@@ -396,8 +398,10 @@
  *  creation / destruction of streaming decompression tracking context.
  *  A tracking context can be re-used multiple times.
  */
+#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
 LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void);
 LZ4LIB_API int                 LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
+#endif /* !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION) */
 
 /*! LZ4_setStreamDecode() :
  *  An LZ4_streamDecode_t context can be allocated once and re-used multiple times.