From 20925d94eb5649df410820e67017a299ce5d867d Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sat, 26 Aug 2000 09:15:32 +0000 Subject: Added some g_return_if_fails and g_return_val_if_fails. 2000-08-25 Christopher James Lahey * e-table-col.c, e-table-config.c, e-table-header.c, e-table-text-model.c: Added some g_return_if_fails and g_return_val_if_fails. svn path=/trunk/; revision=5056 --- widgets/table/e-table-header.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'widgets/table/e-table-header.c') diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c index fddda13da8..0f8f9ed1e9 100644 --- a/widgets/table/e-table-header.c +++ b/widgets/table/e-table-header.c @@ -348,7 +348,7 @@ e_table_header_index (ETableHeader *eth, int col) { g_return_val_if_fail (eth != NULL, -1); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1); - g_return_val_if_fail (col < eth->col_count, -1); + g_return_val_if_fail (col >= 0 && col < eth->col_count, -1); return eth->columns [col]->col_idx; } @@ -376,6 +376,7 @@ ETableCol ** e_table_header_get_columns (ETableHeader *eth) { ETableCol **ret; + int i; g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); @@ -384,6 +385,10 @@ e_table_header_get_columns (ETableHeader *eth) memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); ret [eth->col_count] = NULL; + for (i = 0; i < eth->col_count; i++) { + gtk_object_ref(GTK_OBJECT(ret[i])); + } + return ret; } @@ -479,11 +484,16 @@ e_table_header_remove (ETableHeader *eth, int idx) void e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); } void e_table_header_set_size(ETableHeader *eth, int idx, int size) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + enqueue(eth, idx, size); } @@ -610,21 +620,19 @@ int e_table_header_col_diff (ETableHeader *eth, int start_col, int end_col) { int total, col; - + g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - { - if (start_col < 0) - start_col = 0; - if (end_col > eth->col_count) - end_col = eth->col_count; + if (start_col < 0) + start_col = 0; + if (end_col > eth->col_count) + end_col = eth->col_count; + + total = 0; + for (col = start_col; col < end_col; col++){ - total = 0; - for (col = start_col; col < end_col; col++){ - - total += eth->columns [col]->width; - } + total += eth->columns [col]->width; } return total; -- cgit v1.2.3