From 7c08a0a0c893ca60e6844871e671ead34bf09edb Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 30 Jul 2011 20:50:46 +0200 Subject: Memory leaks fix / code cleanup (bzr r10519) --- src/desktop.cpp | 3 +++ src/dialogs/text-edit.cpp | 1 + src/display/nr-filter-gaussian.cpp | 2 -- src/document.cpp | 11 ++++++++++- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 5e968b08b..bef4ad8cd 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1698,6 +1698,9 @@ static void _reconstruction_start (SPDesktop * desktop) { // printf("Desktop, starting reconstruction\n"); + if (desktop->_reconstruction_old_layer_id){ + g_free(desktop->_reconstruction_old_layer_id); + } desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId()); desktop->_layer_hierarchy->setBottom(desktop->currentRoot()); diff --git a/src/dialogs/text-edit.cpp b/src/dialogs/text-edit.cpp index ce3165632..382b1d630 100644 --- a/src/dialogs/text-edit.cpp +++ b/src/dialogs/text-edit.cpp @@ -752,6 +752,7 @@ sp_text_edit_dialog_read_selection ( GtkWidget *dlg, gtk_text_buffer_set_text (tb, str, strlen (str)); gtk_text_buffer_set_modified (tb, FALSE); } + g_free(phrase); phrase = str; } else { diff --git a/src/display/nr-filter-gaussian.cpp b/src/display/nr-filter-gaussian.cpp index 3a6b425e1..d240c1a43 100644 --- a/src/display/nr-filter-gaussian.cpp +++ b/src/display/nr-filter-gaussian.cpp @@ -226,7 +226,6 @@ static void calcFilter(double const sigma, double b[N]) { double qbeg = 1; // Don't go lower than sigma==2 (we'd probably want a normal convolution in that case anyway) double qend = 2*sigma; double const sigmasqr = sqr(sigma); - double s; do { // Binary search for right q (a linear interpolation scheme is suggested, but this should work fine as well) double const q = (qbeg+qend)/2; // Compute scaled filter coefficients @@ -239,7 +238,6 @@ static void calcFilter(double const sigma, double b[N]) { } else { qend = q; } - s = sqrt(ssqr); } while(qend-qbeg>(sigma/(1<<30))); // Compute filter coefficients double const q = (qbeg+qend)/2; diff --git a/src/document.cpp b/src/document.cpp index 5bcf1bf40..441a5876f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -312,6 +312,15 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; + if (document->uri){ + g_free(document->uri); + } + if (document->base){ + g_free(document->base); + } + if (document->name){ + g_free(document->name); + } #ifndef WIN32 document->uri = prepend_current_dir_if_relative(uri); #else @@ -503,7 +512,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un name = g_strdup_printf(_("Memory document %d"), ++doc_count); doc = createDoc(rdoc, NULL, NULL, name, keepalive); - + g_free(name); return doc; } -- cgit v1.2.3