[gtk/matthiasc/for-master: 5/15] textbtree: Don't opencode realloc
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 5/15] textbtree: Don't opencode realloc
- Date: Mon, 5 Apr 2021 04:13:46 +0000 (UTC)
commit d731ce49ad852ce3331f6a1a757b21a570599791
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Apr 3 22:00:48 2021 -0400
textbtree: Don't opencode realloc
We can just use g_realloc here.
gtk/gtktextbtree.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c
index 19189affc6..bfe628cf77 100644
--- a/gtk/gtktextbtree.c
+++ b/gtk/gtktextbtree.c
@@ -6496,21 +6496,9 @@ inc_count (GtkTextTag *tag, int inc, TagInfo *tagInfoPtr)
if (tagInfoPtr->numTags == tagInfoPtr->arraySize)
{
- GtkTextTag **newTags;
- int *newCounts, newSize;
-
- newSize = 2*tagInfoPtr->arraySize;
- newTags = (GtkTextTag **) g_malloc ((unsigned)
- (newSize*sizeof (GtkTextTag *)));
- memcpy ((void *) newTags, (void *) tagInfoPtr->tags,
- tagInfoPtr->arraySize *sizeof (GtkTextTag *));
- g_free ((char *) tagInfoPtr->tags);
- tagInfoPtr->tags = newTags;
- newCounts = (int *) g_malloc ((unsigned) (newSize*sizeof (int)));
- memcpy ((void *) newCounts, (void *) tagInfoPtr->counts,
- tagInfoPtr->arraySize *sizeof (int));
- g_free ((char *) tagInfoPtr->counts);
- tagInfoPtr->counts = newCounts;
+ int newSize = 2 * tagInfoPtr->arraySize;
+ tagInfoPtr->tags = g_realloc (tagInfoPtr->tags, newSize * sizeof (GtkTextTag *));
+ tagInfoPtr->counts = g_realloc (tagInfoPtr->counts, newSize * sizeof (int));
tagInfoPtr->arraySize = newSize;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]