[xiph-commits] r14543 - branches/theora-multithread/lib/enc

portavales at svn.xiph.org portavales at svn.xiph.org
Wed Feb 27 06:23:38 PST 2008


Author: portavales
Date: 2008-02-27 06:23:38 -0800 (Wed, 27 Feb 2008)
New Revision: 14543

Modified:
   branches/theora-multithread/lib/enc/encode.c
Log:
bugfix: memory leak in return statement at function PickMode of lib/enc/encode.c file

Modified: branches/theora-multithread/lib/enc/encode.c
===================================================================
--- branches/theora-multithread/lib/enc/encode.c	2008-02-26 04:48:48 UTC (rev 14542)
+++ branches/theora-multithread/lib/enc/encode.c	2008-02-27 14:23:38 UTC (rev 14543)
@@ -1442,12 +1442,12 @@
                        ogg_uint32_t *InterError, ogg_uint32_t *IntraError) {
   const int num_threads = cpi->numThreads; /* Number of Threads */
 
-  ogg_uint32_t *InterErrors = malloc(num_threads * sizeof(*InterErrors));
-  ogg_uint32_t *IntraErrors = malloc(num_threads * sizeof(*IntraErrors));
-  THREAD_MV_LIST* mvList = malloc(cpi->pb.UnitFragments * sizeof(*mvList));
-  int* thread_SBRows = malloc(num_threads * sizeof(*thread_SBRows));
-  pthread_t *threads = (pthread_t *)malloc(num_threads*sizeof(*threads));
-  THREAD_PARAM *p = (THREAD_PARAM *)malloc(num_threads*sizeof(*p));
+  ogg_uint32_t *InterErrors = NULL;
+  ogg_uint32_t *IntraErrors = NULL;
+  THREAD_MV_LIST* mvList = NULL;
+  int* thread_SBRows = NULL;
+  pthread_t *threads = NULL;
+  THREAD_PARAM *p = NULL;
 
   ogg_uint32_t  SBrow;      /* Super-Block row number */
   int thread_id;
@@ -1466,6 +1466,15 @@
   if(!cpi->MotionCompensation)
     return 0;
 
+
+  InterErrors = malloc(num_threads * sizeof(*InterErrors));
+  IntraErrors = malloc(num_threads * sizeof(*IntraErrors));
+  mvList = malloc(cpi->pb.UnitFragments * sizeof(*mvList));
+  thread_SBRows = malloc(num_threads * sizeof(*thread_SBRows));
+  threads = (pthread_t *)malloc(num_threads*sizeof(*threads));
+  p = (THREAD_PARAM *)malloc(num_threads*sizeof(*p));
+
+
   /* change the quatization matrix to the one at best Q to compute the
      new error score */
   cpi->MinImprovementForNewMV = (MvThreshTable[QIndex] << 12);



More information about the commits mailing list