From e8f2280c7851c64b6536724d2ce60e049dd86b26 Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 14 Aug 2004 15:58:11 +0000 Subject: [PATCH] ameliorate use of garray by preallocating 10 execmode git-svn-id: http://ltt.polymtl.ca/svn@741 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttv/lttv/state.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/lttv/lttv/state.c b/ltt/branches/poly/lttv/lttv/state.c index 2ff087f4..979bfda1 100644 --- a/ltt/branches/poly/lttv/lttv/state.c +++ b/ltt/branches/poly/lttv/lttv/state.c @@ -26,6 +26,8 @@ #include #include +#define PREALLOCATED_EXECUTION_STACK 10 + LttvExecutionMode LTTV_STATE_MODE_UNKNOWN, LTTV_STATE_USER_MODE, @@ -322,8 +324,8 @@ static void copy_process_state(gpointer key, gpointer value,gpointer user_data) process = (LttvProcessState *)value; new_process = g_new(LttvProcessState, 1); *new_process = *process; - new_process->execution_stack = g_array_new(FALSE, FALSE, - sizeof(LttvExecutionState)); + new_process->execution_stack = g_array_sized_new(FALSE, FALSE, + sizeof(LttvExecutionState), PREALLOCATED_EXECUTION_STACK); g_array_set_size(new_process->execution_stack,process->execution_stack->len); for(i = 0 ; i < process->execution_stack->len; i++) { g_array_index(new_process->execution_stack, LttvExecutionState, i) = @@ -801,8 +803,8 @@ lttv_state_create_process(LttvTracefileState *tfs, LttvProcessState *parent, process->creation_time.tv_nsec); process->pid_time = g_quark_from_string(buffer); process->last_cpu = tfs->cpu_name; - process->execution_stack = g_array_new(FALSE, FALSE, - sizeof(LttvExecutionState)); + process->execution_stack = g_array_sized_new(FALSE, FALSE, + sizeof(LttvExecutionState), PREALLOCATED_EXECUTION_STACK); g_array_set_size(process->execution_stack, 1); es = process->state = &g_array_index(process->execution_stack, LttvExecutionState, 0); -- 2.34.1