Subject: | [PATCH] const all global data |
This patch makes Compress-Raw-Zlib use no perl caused RW static/global memory. On some OSes/CCs, this allows complete removal of the RW initialized memory section from shared library. Since this patches the bzip src code, maybe it needs to be submitted upstream. IDK if it is worth it.
Subject: | 0001-const-all-global-data.patch |
From 35a8a6985c51130f1e5a50cbef13986b8d3223a2 Mon Sep 17 00:00:00 2001
From: bulk88 <bulk88@hotmail.com>
Date: Mon, 5 Jan 2015 03:54:05 -0500
Subject: [PATCH] const all global data
---
Zlib.xs | 4 ++++
zlib-src/trees.c | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/Zlib.xs b/Zlib.xs
index 2eb78c0..c340332 100644
--- a/Zlib.xs
+++ b/Zlib.xs
@@ -274,6 +274,10 @@ static const char my_z_errmsg[][32] = {
# define NO_WRITEABLE_DATA
#endif
+/* for efficiency, optimize trace to a constant in regular builds */
+#undef NO_WRITEABLE_DATA
+#define NO_WRITEABLE_DATA
+
#define TRACE_DEFAULT 0
#ifdef NO_WRITEABLE_DATA
diff --git a/zlib-src/trees.c b/zlib-src/trees.c
index 9dbd905..622859a 100644
--- a/zlib-src/trees.c
+++ b/zlib-src/trees.c
@@ -122,13 +122,13 @@ struct static_tree_desc_s {
int max_length; /* max bit length for the codes */
};
-local static_tree_desc static_l_desc =
+local const static_tree_desc static_l_desc =
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
-local static_tree_desc static_d_desc =
+local const static_tree_desc static_d_desc =
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
-local static_tree_desc static_bl_desc =
+local const static_tree_desc static_bl_desc =
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
/* ===========================================================================
--
1.7.9.msysgit.0