[gst-cvs] gst-plugins-good: jpegenc: free/malloc instead of realloc, avoids memcpy

Tim Müller tpm at kemper.freedesktop.org
Sat Dec 11 09:10:38 PST 2010


Module: gst-plugins-good
Branch: master
Commit: 100673bf14972e9bf67247f449fac92c1e3521ab
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=100673bf14972e9bf67247f449fac92c1e3521ab

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Fri May 28 15:27:14 2010 +0100

jpegenc: free/malloc instead of realloc, avoids memcpy

---

 ext/jpeg/gstjpegenc.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c
index 8f81964..e562867 100644
--- a/ext/jpeg/gstjpegenc.c
+++ b/ext/jpeg/gstjpegenc.c
@@ -520,11 +520,12 @@ gst_jpegenc_resync (GstJpegEnc * jpegenc)
         jpegenc->h_samp[i], jpegenc->v_samp[i]);
     jpegenc->cinfo.comp_info[i].h_samp_factor = jpegenc->h_samp[i];
     jpegenc->cinfo.comp_info[i].v_samp_factor = jpegenc->v_samp[i];
-    jpegenc->line[i] = g_realloc (jpegenc->line[i],
-        jpegenc->v_max_samp * DCTSIZE * sizeof (char *));
+    g_free (jpegenc->line[i]);
+    jpegenc->line[i] = g_new (guchar *, jpegenc->v_max_samp * DCTSIZE);
     if (!jpegenc->planar) {
       for (j = 0; j < jpegenc->v_max_samp * DCTSIZE; j++) {
-        jpegenc->row[i][j] = g_realloc (jpegenc->row[i][j], width);
+        g_free (jpegenc->row[i][j]);
+        jpegenc->row[i][j] = g_malloc (width);
         jpegenc->line[i][j] = jpegenc->row[i][j];
       }
     }





More information about the Gstreamer-commits mailing list