aboutsummaryrefslogtreecommitdiff
path: root/nx-X11
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2019-06-20 19:53:39 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2019-06-22 11:30:52 +0200
commite440e722d8639411722d8a2499df46fe18c45f31 (patch)
tree3ca6b36c535d240281b62c2e0630f06be01ca9d8 /nx-X11
parentd48824195009b2497b4233c9d3f2a8f9c1e6a2d7 (diff)
downloadnx-libs-e440e722d8639411722d8a2499df46fe18c45f31.tar.gz
nx-libs-e440e722d8639411722d8a2499df46fe18c45f31.tar.bz2
nx-libs-e440e722d8639411722d8a2499df46fe18c45f31.zip
compext/Png.c: simplify srcBuf allocation
Diffstat (limited to 'nx-X11')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/compext/Png.c43
1 files changed, 13 insertions, 30 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
index e80f3879d..77a1941ea 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/compext/Png.c
@@ -481,47 +481,23 @@ char *PngCompressData(XImage *image, int *compressed_size)
return NULL;
}
+ int count;
if (color_type == PNG_COLOR_TYPE_PALETTE)
{
- srcBuf = (CARD8 *) malloc(w * sizeof(CARD8));
-
- if (srcBuf == NULL)
- {
- #ifdef PANIC
- fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n",
- (int) (w * sizeof(CARD8)));
- #endif
-
- free(image_index);
-
- return NULL;
- }
-
- /*
- * TODO: Be sure the padded bytes are cleaned.
- * It would be better to set to zero the bytes
- * that are not aligned to the word boundary
- * at the end of the procedure.
- */
-
- memset(srcBuf, 0, w * sizeof(CARD8));
+ count = w;
}
else
{
- srcBuf = (CARD8 *) malloc(w * 3 * sizeof(CARD8));
-
- /*
- * TODO: See above.
- */
-
- memset(srcBuf, 0, w * 3 * sizeof(CARD8));
+ count = 3 * w;
}
+ srcBuf = (CARD8 *) calloc(count, sizeof(CARD8));
+
if (srcBuf == NULL)
{
#ifdef PANIC
fprintf(stderr, "******PngCompressData: PANIC! Cannot allocate [%d] bytes.\n",
- w * 3);
+ (int) (count * sizeof(CARD8)));
#endif
free(pngCompBuf);
@@ -530,6 +506,13 @@ char *PngCompressData(XImage *image, int *compressed_size)
return NULL;
}
+ /*
+ * TODO: Be sure the padded bytes are cleaned.
+ * It would be better to set to zero the bytes
+ * that are not aligned to the word boundary
+ * at the end of the procedure.
+ */
+
for (dy = 0; dy < h; dy++)
{
if (color_type == PNG_COLOR_TYPE_RGB)