Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Fixes two memleaks.

-- Kenneth
From 4cd88904ea50619dbc0965ea2683ea270a74013b Mon Sep 17 00:00:00 2001
From: Kenneth Venken <kenneth.venken@gmail.com>
Date: Wed, 26 Jan 2011 19:39:13 +0100
Subject: [PATCH] cpp cleanliness: fixed some memleaks

---
 fpicker/source/unx/kde/kdecommandthread.cxx |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/fpicker/source/unx/kde/kdecommandthread.cxx 
b/fpicker/source/unx/kde/kdecommandthread.cxx
index 499c3ad..1eef244 100644
--- a/fpicker/source/unx/kde/kdecommandthread.cxx
+++ b/fpicker/source/unx/kde/kdecommandthread.cxx
@@ -128,6 +128,7 @@ void KDECommandThread::handleCommand( const QString &rString, bool &bQuit )
         bQuit = true;
         kapp->exit();
         kapp->wakeUpGuiThread();
+        delete pTokens, pTokens = NULL;
     }
     else
         kapp->postEvent( m_pObject, new KDECommandEvent( qCommand, pTokens ) );
-- 
1.7.1

From 736d39d19d4c0bb6e6f973efdf5d3091e41d3741 Mon Sep 17 00:00:00 2001
From: Kenneth Venken <kenneth.venken@gmail.com>
Date: Wed, 26 Jan 2011 20:38:17 +0100
Subject: [PATCH] cpp cleanliness: fixed some memleaks

---
 i18npool/source/breakiterator/gendict.cxx |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/i18npool/source/breakiterator/gendict.cxx b/i18npool/source/breakiterator/gendict.cxx
index 31aaeaa..f035da3 100644
--- a/i18npool/source/breakiterator/gendict.cxx
+++ b/i18npool/source/breakiterator/gendict.cxx
@@ -36,6 +36,8 @@
 #include <sal/types.h>
 #include <rtl/strbuf.hxx>
 #include <rtl/ustring.hxx>
+#include <vector>
+using std::vector;
 
 using namespace ::rtl;
 
@@ -71,7 +73,8 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
     fprintf(cfp, "extern \"C\" {\n");
 
     sal_Int32 count, i, j;
-    sal_Int32 lenArrayCurr = 0, lenArrayCount = 0, lenArrayLen = 0, *lenArray = NULL, 
charArray[0x10000];
+    sal_Int32 lenArrayCurr = 0, charArray[0x10000];
+    vector<sal_Int32> lenArray;
     sal_Bool exist[0x10000];
     for (i = 0; i < 0x10000; i++) {
         exist[i] = sal_False;
@@ -97,15 +100,13 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 
         if (*u != current) {
         if (*u < current)
-        printf("u %x, current %x, count %d, lenArrayCount %d\n", *u, current,
-                    sal::static_int_cast<int>(count), sal::static_int_cast<int>(lenArrayCount));
+        printf("u %x, current %x, count %d, lenArray.size() %d\n", *u, current,
+                    sal::static_int_cast<int>(count), sal::static_int_cast<int>(lenArray.size()));
         current = *u;
-        charArray[current] = lenArrayCount;
+        charArray[current] = lenArray.size();
         }
 
-        if (lenArrayLen <= lenArrayCount+1)
-        lenArray = (sal_Int32*) realloc(lenArray, (lenArrayLen += 1000) * sizeof(sal_Int32));
-        lenArray[lenArrayCount++] = lenArrayCurr;
+        lenArray.push_back(lenArrayCurr);
 
         exist[u[0]] = sal_True;
         for (i = 1; i < len; i++) {            // start from second character, 
@@ -116,15 +117,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
         fprintf(cfp, "0x%04x, ", u[i]);
         }
     }
-    lenArray[lenArrayCount++] = lenArrayCurr; // store last ending pointer
-    charArray[current+1] = lenArrayCount;
+    lenArray.push_back( lenArrayCurr ); // store last ending pointer
+
+    charArray[current+1] = lenArray.size();
     fprintf(cfp, "\n};\n");
 
     // generate lenArray 
     fprintf(cfp, "static const sal_Int32 lenArray[] = {\n\t");
     count = 1;
     fprintf(cfp, "0x%x, ", 0); // insert one slat for skipping 0 in index2 array.
-    for (i = 0; i < lenArrayCount; i++) {
+    for (i = 0; i < lenArray.size(); i++) {
         fprintf(cfp, "0x%lx, ", static_cast<long unsigned int>(lenArray[i]));
         if (count == 0xf) {
         count = 0;
@@ -133,8 +135,6 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
     }
     fprintf(cfp, "\n};\n");
 
-    free(lenArray);
-
     // generate index1 array
     fprintf (cfp, "static const sal_Int16 index1[] = {\n\t");
     sal_Int16 set[0x100];
-- 
1.7.1


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.