[vte/wip/sixels: 90/111] sixelparser: Use g_try_malloc()




commit f2b6c3cbac220f457b5204613f038a1568b4d924
Author: Hans Petter Jansson <hpj cl no>
Date:   Sat Aug 8 20:42:49 2020 +0200

    sixelparser: Use g_try_malloc()

 src/sixelparser.cc | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/src/sixelparser.cc b/src/sixelparser.cc
index 86ca1438..90370e4c 100644
--- a/src/sixelparser.cc
+++ b/src/sixelparser.cc
@@ -157,15 +157,13 @@ sixel_image_init(sixel_image_t *image,
         size = (size_t)(width * height) * sizeof(sixel_color_no_t);
         image->width = width;
         image->height = height;
-        image->data = (sixel_color_no_t *)g_malloc(size);
+        image->data = (sixel_color_no_t *) g_try_malloc0(size);
         image->ncolors = 2;
         image->use_private_register = use_private_register;
 
         if (image->data == NULL)
                 goto out;
 
-        memset(image->data, 0, size);
-
         image->palette[0] = bgcolor;
 
         if (image->use_private_register)
@@ -193,7 +191,7 @@ image_buffer_resize(sixel_image_t *image, int width, int height)
                 return 0;
 
         size = (size_t)(width * height) * sizeof(sixel_color_no_t);
-        alt_buffer = (sixel_color_no_t *)g_malloc(size);
+        alt_buffer = (sixel_color_no_t *) g_try_malloc(size);
         if (alt_buffer == NULL) {
                 status = -1;
                 goto out;


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