From dccbd21efa62795fe0baff16e140345e8a7bfe62 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 31 Mar 2012 13:54:00 -0500 Subject: [PATCH] Bugfix: Do not de-allocate the additional array Do not de-allocate this array when some allocation error happens. The data is defined outside of this function, so leave it to the caller to handle deallocation. This allows for giving the caller more choices when trying to decided what to do on allocation problem. For example, some program may want to try to continue anyway even if there is an allocation problem. It will be tricky, but in such a case one would just have to make do with what is already allocated. --- level_1/fl_console/c/console.c | 50 +----------------------------------------- 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/level_1/fl_console/c/console.c b/level_1/fl_console/c/console.c index 69fdf30..81b0e7d 100644 --- a/level_1/fl_console/c/console.c +++ b/level_1/fl_console/c/console.c @@ -65,13 +65,6 @@ extern "C"{ f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step); if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -92,14 +85,8 @@ extern "C"{ f_status allocation_status = f_status_initialize; f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step); - if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while + if (f_macro_test_for_allocation_errors(allocation_status)) { f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -132,13 +119,6 @@ extern "C"{ f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step); if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -161,13 +141,6 @@ extern "C"{ f_resize_string_lengths(allocation_status, extra_initiator, extra_initiator.size + f_console_default_allocation_step); if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -198,13 +171,6 @@ extern "C"{ } if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -231,13 +197,6 @@ extern "C"{ } if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } @@ -260,13 +219,6 @@ extern "C"{ f_resize_string_lengths(allocation_status, (*remaining), remaining->size + f_console_default_allocation_step); if (f_macro_test_for_allocation_errors(allocation_status)) { - f_string_length i = 0; - - while (i < total_parameters) { - f_delete_string_lengths(status, parameters[i].additional); - i++; - } // while - f_delete_string_lengths(status, extra_initiator); return allocation_status; } -- 1.8.3.1