[PATCH spice-server 11/11] lz4-encoder: Use GLib memory functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/lz4-encoder.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/server/lz4-encoder.c b/server/lz4-encoder.c
index fe736d272..ca9b1b825 100644
--- a/server/lz4-encoder.c
+++ b/server/lz4-encoder.c
@@ -53,7 +53,8 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
     int num_lines = 0;
     int total_lines = 0;
     int in_size, enc_size, out_size, already_copied;
-    uint8_t *in_buf, *compressed_lines;
+    const char *in_buf;
+    char *compressed_lines;
     uint8_t *out_buf = io_ptr;
     LZ4_stream_t *stream = LZ4_createStream();
 
@@ -70,22 +71,22 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
             LZ4_freeStream(stream);
             return 0;
         }
-        in_buf = lines;
+        in_buf = (const char *) lines;
         in_size = stride * num_lines;
         lines += in_size;
         int bound_size = LZ4_compressBound(in_size);
-        compressed_lines = (uint8_t *) malloc(bound_size + 4);
+        compressed_lines = g_new(char, bound_size + 4);
 #ifdef HAVE_LZ4_COMPRESS_FAST_CONTINUE
-        enc_size = LZ4_compress_fast_continue(stream, (const char *) in_buf,
-                                              (char *) compressed_lines + 4, in_size,
+        enc_size = LZ4_compress_fast_continue(stream, in_buf,
+                                              compressed_lines + 4, in_size,
                                               bound_size, 1);
 #else
-        enc_size = LZ4_compress_continue(stream, (const char *) in_buf,
-                                         (char *) compressed_lines + 4, in_size);
+        enc_size = LZ4_compress_continue(stream, in_buf,
+                                         compressed_lines + 4, in_size);
 #endif
         if (enc_size <= 0) {
             spice_error("compress failed!");
-            free(compressed_lines);
+            g_free(compressed_lines);
             LZ4_freeStream(stream);
             return 0;
         }
@@ -100,7 +101,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
             num_io_bytes = enc->usr->more_space(enc->usr, &io_ptr);
             if (num_io_bytes <= 0) {
                 spice_error("more space failed");
-                free(compressed_lines);
+                g_free(compressed_lines);
                 LZ4_freeStream(stream);
                 return 0;
             }
@@ -110,7 +111,7 @@ int lz4_encode(Lz4EncoderContext *lz4, int height, int stride, uint8_t *io_ptr,
         out_buf += enc_size;
         num_io_bytes -= enc_size;
 
-        free(compressed_lines);
+        g_free(compressed_lines);
         total_lines += num_lines;
     } while (total_lines < height);
 
-- 
2.13.5

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]