]> Kevux Git Server - fll/commitdiff
Bugfix: Do not de-allocate the additional array
authorKevin Day <kevin@kevux.org>
Sat, 31 Mar 2012 18:54:00 +0000 (13:54 -0500)
committerKevin Day <kevin@kevux.org>
Sat, 31 Mar 2012 18:54:00 +0000 (13:54 -0500)
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

index 69fdf30efd616581922701657bd96029514ebc8d..81b0e7d13be7ed32010bf82a664c4145ab12e720 100644 (file)
@@ -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;
               }