On 4/24/24 12:34, Daniel P. Smith wrote:
Begin moving core state, in this case the gunzip window, into struct
gunzip_state to allow a per decompression instance. In doing so, drop the
define aliasing of window to slide.

Signed-off-by: Daniel P. Smith <dpsm...@apertussolutions.com>
---
  xen/common/gzip/gunzip.c  | 21 ++++++++----
  xen/common/gzip/inflate.c | 68 +++++++++++++++++++--------------------
  2 files changed, 48 insertions(+), 41 deletions(-)

diff --git a/xen/common/gzip/gunzip.c b/xen/common/gzip/gunzip.c
index b7cadadcca8b..e47f10ae19ad 100644
--- a/xen/common/gzip/gunzip.c
+++ b/xen/common/gzip/gunzip.c
@@ -4,10 +4,12 @@
  #include <xen/lib.h>
  #include <xen/mm.h>
-static unsigned char *__initdata window;
-
  #define WSIZE           0x80000000U
+struct gunzip_state {
+    unsigned char *window;
+};
+
  static unsigned char *__initdata inbuf;
  static unsigned int __initdata insize;
@@ -43,7 +45,7 @@ typedef unsigned long ulg;
  #endif
static long __initdata bytes_out;
-static void flush_window(void);
+static void flush_window(struct gunzip_state *s);
static __init void error(const char *x)
  {
@@ -62,7 +64,7 @@ static __init uch get_byte(void) {
#include "inflate.c" -static __init void flush_window(void)
+static __init void flush_window(struct gunzip_state *s)
  {
      /*
       * The window is equal to the output buffer therefore only need to
@@ -72,7 +74,7 @@ static __init void flush_window(void)
      unsigned int n;
      unsigned char *in, ch;
- in = window;
+    in = s->window;
      for ( n = 0; n < outcnt; n++ )
      {
          ch = *in++;
@@ -99,12 +101,17 @@ __init int gzip_check(char *image, unsigned long image_len)
__init int perform_gunzip(char *output, char *image, unsigned long image_len)
  {
+    struct gunzip_state *s;
      int rc;
if ( !gzip_check(image, image_len) )
          return 1;
- window = (unsigned char *)output;
+    s = (struct gunzip_state *)malloc(sizeof(struct gunzip_state));

Looks like I inadvertently dropped the corresponding free when breaking up the monolithic patch.

v/r,
dps

Reply via email to