[geany/geany] 235b86: Use GSlice to allocate find_range() elements

Colomban Wendling git-noreply at xxxxx
Sun Mar 24 17:47:55 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 24 Mar 2013 17:47:55 UTC
Commit:      235b8613fb8fabf16b9bc3a8fe5b26b98a26eb80
             https://github.com/geany/geany/commit/235b8613fb8fabf16b9bc3a8fe5b26b98a26eb80

Log Message:
-----------
Use GSlice to allocate find_range() elements


Modified Paths:
--------------
    src/search.c

Modified: src/search.c
11 files changed, 6 insertions(+), 5 deletions(-)
===================================================================
@@ -1143,7 +1143,8 @@ void search_show_find_in_files_dialog(const gchar *dir)
 /* find all in the given range.
  * Returns a list of allocated Sci_TextToFind, should be freed using:
  *
- * 	g_slist_foreach(matches, g_free);
+ * 	foreach_slist(node, matches)
+ * 		g_slice_free(struct Sci_TextToFind, node->data);
  * 	g_slist_free(matches); */
 static GSList *find_range(ScintillaObject *sci, gint flags, struct Sci_TextToFind *ttf)
 {
@@ -1158,7 +1159,7 @@ static GSList *find_range(ScintillaObject *sci, gint flags, struct Sci_TextToFin
 		if (ttf->chrgText.cpMax > ttf->chrg.cpMax)
 			break; /* found text is partially out of range */
 
-		matches = g_slist_prepend(matches, g_memdup(ttf, sizeof *ttf));
+		matches = g_slist_prepend(matches, g_slice_copy(sizeof *ttf, ttf));
 		ttf->chrg.cpMin = ttf->chrgText.cpMax;
 
 		/* avoid rematching with empty matches like "(?=[a-z])" or "^$".
@@ -1204,7 +1205,7 @@ gint search_mark_all(GeanyDocument *doc, const gchar *search_text, gint flags)
 		}
 		count++;
 
-		g_free(m);
+		g_slice_free1(sizeof *m, m);
 	}
 	g_slist_free(matches);
 
@@ -2082,7 +2083,7 @@ static gint find_document_usage(GeanyDocument *doc, const gchar *search_text, gi
 		}
 		count++;
 
-		g_free(m);
+		g_slice_free1(sizeof *m, m);
 	}
 	g_slist_free(matches);
 	g_free(short_file_name);
@@ -2175,7 +2176,7 @@ guint search_replace_range(ScintillaObject *sci, struct Sci_TextToFind *ttf,
 			ttf->chrg.cpMax += offset;
 		}
 
-		g_free(m);
+		g_slice_free1(sizeof *m, m);
 	}
 	g_slist_free(matches);
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list