[evolution-data-server] Bug 773363 - Do not use alloca() in camel-folder-thread.c
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 773363 - Do not use alloca() in camel-folder-thread.c
- Date: Mon, 24 Oct 2016 19:30:42 +0000 (UTC)
commit bda5a4c052ee1ad7eb139dcd4b83308b5b340fc8
Author: Glen Whitney <gwhitneycom1 pobox com>
Date: Mon Oct 24 21:30:18 2016 +0200
Bug 773363 - Do not use alloca() in camel-folder-thread.c
src/camel/camel-folder-thread.c | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/src/camel/camel-folder-thread.c b/src/camel/camel-folder-thread.c
index 277ccea..9ff205d 100644
--- a/src/camel/camel-folder-thread.c
+++ b/src/camel/camel-folder-thread.c
@@ -358,12 +358,7 @@ dump_tree_rec (struct _tree_info *info,
CamelFolderThreadNode *c,
gint depth)
{
- gchar *p;
- gint count = 0;
-
- p = alloca (depth * 2 + 1);
- memset (p, ' ', depth * 2);
- p[depth * 2] = 0;
+ gint count = 0, indent = depth * 2;
while (c) {
if (g_hash_table_lookup (info->visited, c)) {
@@ -373,14 +368,14 @@ dump_tree_rec (struct _tree_info *info,
}
if (c->message) {
printf (
- "%s %p Subject: %s <%08x%08x>\n",
- p, (gpointer) c,
+ "%*s %p Subject: %s <%08x%08x>\n",
+ indent, "", (gpointer) c,
camel_message_info_get_subject (c->message),
camel_message_info_get_message_id (c->message)->id.part.hi,
camel_message_info_get_message_id (c->message)->id.part.lo);
count += 1;
} else {
- printf ("%s %p <empty>\n", p, (gpointer) c);
+ printf ("%*s %p <empty>\n", indent, "", (gpointer) c);
}
if (c->child)
count += dump_tree_rec (info, c->child, depth + 1);
@@ -439,7 +434,9 @@ sort_thread (CamelFolderThreadNode **cp)
}
if (size < 2)
return;
- carray = alloca (size * sizeof (CamelFolderThreadNode *));
+
+ carray = g_new (CamelFolderThreadNode *, size);
+
c = *cp;
size = 0;
while (c) {
@@ -459,6 +456,8 @@ sort_thread (CamelFolderThreadNode **cp)
size--;
} while (size >= 0);
*cp = head;
+
+ g_free (carray);
}
static guint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]