[gnumeric] SheetFilter: Use heap, not stack, allocation.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] SheetFilter: Use heap, not stack, allocation.
- Date: Thu, 30 Nov 2017 19:08:49 +0000 (UTC)
commit 3ac794c83e385b93b8e594782f1dc84ef149aa52
Author: Morten Welinder <terra gnome org>
Date: Thu Nov 30 14:07:40 2017 -0500
SheetFilter: Use heap, not stack, allocation.
Potentially this could use 8*16M on the stack.
ChangeLog | 3 +++
NEWS | 1 +
src/sheet-filter.c | 7 +++++--
3 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ab33923..d46bc64 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2017-11-30 Morten Welinder <terra gnome org>
+ * src/sheet-filter.c (gnm_filter_combo_apply): Use heap, not
+ stack, allocation.
+
* src/sheet-style.c (sheet_style_find_conflicts): Use heap, not
stack, allocation.
diff --git a/NEWS b/NEWS
index 4575e65..0ff2744 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Morten:
* Fix combo object icon.
* Code cleanups for main binary.
* Fix potential crash in gtk scroll bar bug workaround.
+ * Avoid large stack use here and there.
--------------------------------------------------------------------------
Gnumeric 1.12.36
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index 4360920..f88d93e 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -510,7 +510,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.count = 0.5 + cond->count * (end_row - start_row + 1) /100.;
if (data.count < 1)
data.count = 1;
- data.vals = g_alloca (sizeof (GnmValue *) * data.count);
+ data.vals = g_new (GnmValue const *, data.count);
sheet_foreach_cell_in_range (filter->sheet,
CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row,
@@ -520,6 +520,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data);
+ g_free (data.vals);
} else {
FilterPercentage data;
gnm_float offset;
@@ -544,7 +545,8 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
data.find_max = (cond->op[0] & 0x1) ? FALSE : TRUE;
data.elements = 0;
data.count = cond->count;
- data.vals = g_alloca (sizeof (GnmValue *) * data.count);
+ data.vals = g_new (GnmValue const *, data.count);
+
sheet_foreach_cell_in_range (filter->sheet,
CELL_ITER_IGNORE_HIDDEN | CELL_ITER_IGNORE_BLANK,
col, start_row, col, end_row,
@@ -554,6 +556,7 @@ gnm_filter_combo_apply (GnmFilterCombo *fcombo, Sheet *target_sheet)
CELL_ITER_IGNORE_HIDDEN,
col, start_row, col, end_row,
(CellIterFunc) cb_hide_unwanted_items, &data);
+ g_free (data.vals);
}
} else
g_warning ("Invalid operator %d", cond->op[0]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]