From 46addfad2d354ab7a23b930debbb8334135cd786 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 21 Nov 2019 20:24:43 -0600 Subject: [PATCH] Update: implement *_delete_simple() and *_destroy_simple() macros and related changes I do not want a *_delete() and *_destroy() that doesn't provide the ability to handle a status code. However, in practice, the *_delete() and *_destroy() macros rarely needed the status response checked. Additional f_status variables were created only to be provided for the status parameter of the stated macros. This is a waste. This provides and utilizes alternative *_delete() and *_destroy() macros called *_delete_simple() and *_destroy_simple(). These simple macros do not accept or process the status code. The resulting code is simpler and easier. I am on the fence whether or not to throw away the *_delete() and *_destroy() macros that utilize a status parameter. Future versions may or may not replace the *_delete() and *_destroy() with the *_delete_simple() and *_destroy_simple() macros. Update *_delete() and *_destroy() macros as needed. --- level_0/f_console/c/console.c | 69 +++---- level_0/f_fss/c/fss.h | 219 +++++++++++++++++---- level_0/f_memory/c/memory.h | 87 +++++++- level_0/f_string/c/string.h | 91 +++++++-- level_0/f_type/c/type_array.h | 5 +- level_1/fl_color/c/color.h | 22 +++ level_1/fl_directory/c/directory.c | 12 +- level_1/fl_fss/c/fss_basic.c | 54 ++--- level_1/fl_fss/c/fss_basic_list.c | 20 +- level_1/fl_fss/c/fss_extended.c | 63 +++--- level_1/fl_fss/c/fss_extended_list.c | 160 ++++++--------- level_2/fll_execute/c/execute.c | 46 ++--- level_2/fll_program/c/program.c | 3 +- level_3/byte_dump/c/byte_dump.c | 9 +- level_3/firewall/c/firewall.c | 18 +- level_3/firewall/c/private-firewall.c | 89 ++++----- .../fss_basic_list_read/c/fss_basic_list_read.c | 43 ++-- .../c/private-fss_basic_list_read.c | 9 +- .../c/private-fss_basic_list_read.h | 13 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 15 +- level_3/fss_basic_read/c/fss_basic_read.c | 43 ++-- level_3/fss_basic_read/c/private-fss_basic_read.c | 9 +- level_3/fss_basic_read/c/private-fss_basic_read.h | 13 +- level_3/fss_basic_write/c/fss_basic_write.c | 14 +- level_3/fss_extended_read/c/fss_extended_read.c | 43 ++-- .../c/private-fss_extended_read.c | 9 +- .../c/private-fss_extended_read.h | 13 +- level_3/fss_extended_write/c/fss_extended_write.c | 14 +- level_3/fss_status_code/c/fss_status_code.c | 9 +- level_3/init/c/private-init.c | 18 +- level_3/status_code/c/status_code.c | 8 +- 31 files changed, 708 insertions(+), 532 deletions(-) diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 48b763a..88f8283 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -111,13 +111,11 @@ extern "C" { parameter_counter = needs_additional.array[0]; if (parameters.parameter[parameter_counter].additional.used >= parameters.parameter[parameter_counter].additional.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, parameters.parameter[parameter_counter].additional, parameters.parameter[parameter_counter].additional.size + f_console_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, parameters.parameter[parameter_counter].additional, parameters.parameter[parameter_counter].additional.size + f_console_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -163,7 +161,7 @@ extern "C" { status = f_utf_char_to_character(arguments.argv[location] + sub_location, max_width, &character_argument_utf); if (status != f_none) { - f_macro_string_lengths_delete(status, needs_additional); + f_macro_string_lengths_delete_simple(needs_additional); return status; } @@ -172,7 +170,7 @@ extern "C" { status = f_utf_char_to_character((f_string) parameters.parameter[parameter_counter].symbol_short, max_width, &character_console_utf); if (status != f_none) { - f_macro_string_lengths_delete(status, needs_additional); + f_macro_string_lengths_delete_simple(needs_additional); return status; } @@ -195,13 +193,11 @@ extern "C" { } if (parameters.parameter[parameter_counter].locations.used >= parameters.parameter[parameter_counter].locations.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, parameters.parameter[parameter_counter].locations, parameters.parameter[parameter_counter].locations.size + f_console_default_allocation_step); + f_macro_string_lengths_resize(status, parameters.parameter[parameter_counter].locations, parameters.parameter[parameter_counter].locations.size + f_console_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -219,13 +215,11 @@ extern "C" { if (parameters.parameter[parameter_counter].has_additional) { if (needs_additional.used + parameters.parameter[parameter_counter].has_additional > needs_additional.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, needs_additional, needs_additional.used + parameters.parameter[parameter_counter].has_additional); - f_macro_string_lengths_resize(allocation_status, needs_additional, needs_additional.used + parameters.parameter[parameter_counter].has_additional); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -258,13 +252,11 @@ extern "C" { } if (parameters.parameter[parameter_counter].locations.used >= parameters.parameter[parameter_counter].locations.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, parameters.parameter[parameter_counter].locations, parameters.parameter[parameter_counter].locations.size + f_console_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, parameters.parameter[parameter_counter].locations, parameters.parameter[parameter_counter].locations.size + f_console_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -278,13 +270,11 @@ extern "C" { if (parameters.parameter[parameter_counter].has_additional) { if (needs_additional.used + parameters.parameter[parameter_counter].has_additional > needs_additional.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, needs_additional, needs_additional.used + parameters.parameter[parameter_counter].has_additional); + f_macro_string_lengths_resize(status, needs_additional, needs_additional.used + parameters.parameter[parameter_counter].has_additional); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -301,13 +291,11 @@ extern "C" { if (!found) { // populate list of remaining parameters.parameter not associated with anything. if (remaining->used >= remaining->size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, (*remaining), remaining->size + f_console_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, (*remaining), remaining->size + f_console_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, needs_additional); - return f_status_set_error(allocation_status); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(needs_additional); + return status; } } @@ -326,10 +314,7 @@ extern "C" { status = f_none; } - { - f_status allocation_status = f_none; - f_macro_string_lengths_delete(allocation_status, needs_additional); - } + f_macro_string_lengths_delete_simple(needs_additional); return status; } diff --git a/level_0/f_fss/c/fss.h b/level_0/f_fss/c/fss.h index ecb7fef..5d7eaea 100644 --- a/level_0/f_fss/c/fss.h +++ b/level_0/f_fss/c/fss.h @@ -15,6 +15,7 @@ // fll-0 includes #include +#include #include #include @@ -114,10 +115,13 @@ extern "C" { #define f_macro_fss_delimits_clear(delimits) f_macro_memory_structure_clear(delimits) - #define f_macro_fss_delimits_new(status, delimits) f_macro_string_locations_new(status, delimits) + #define f_macro_fss_delimits_new(status, delimits) f_macro_string_locations_new(status, delimits) #define f_macro_fss_delimits_delete(status, delimits) f_macro_string_locations_delete(status, delimits) #define f_macro_fss_delimits_destroy(status, delimits) f_macro_string_locations_destroy(status, delimits) + #define f_macro_fss_delimits_delete_simple(delimits) f_macro_string_locations_delete_simple(delimits) + #define f_macro_fss_delimits_destroy_simple(delimits) f_macro_string_locations_destroy_simple(delimits) + #define f_macro_fss_delimits_resize(status, delimits, new_length) f_macro_string_locations_resize(status, delimits, new_length) #define f_macro_fss_delimits_adjust(status, delimits, new_length) f_macro_string_locations_adjust(status, delimits, new_length) #endif // _di_f_fss_delimits_ @@ -159,9 +163,12 @@ extern "C" { #define f_macro_fss_headers_new(status, headers, length) f_macro_memory_structure_new(status, headers, f_fss_header, length) - #define f_macro_fss_headers_delete(status, headers) f_macro_memory_structure_delete(status, headers, f_fss_header) + #define f_macro_fss_headers_delete(status, headers) f_macro_memory_structure_delete(status, headers, f_fss_header) #define f_macro_fss_headers_destroy(status, headers) f_macro_memory_structure_destroy(status, headers, f_fss_header) + #define f_macro_fss_headers_delete_simple(headers) f_macro_memory_structure_delete_simple(headers, f_fss_header) + #define f_macro_fss_headers_destroy_simple(headers) f_macro_memory_structure_destroy_simple(headers, f_fss_header) + #define f_macro_fss_headers_resize(status, headers, new_length) f_macro_memory_structure_resize(status, headers, f_fss_header, new_length) #define f_macro_fss_headers_adjust(status, headers, new_length) f_macro_memory_structure_adjust(status, headers, f_fss_header, new_length) #endif // _di_f_fss_headers_ @@ -177,8 +184,11 @@ extern "C" { #define f_macro_fss_object_new(status, object, length) status = f_memory_new((void **) & object, sizeof(f_fss_object), length) - #define f_macro_fss_object_delete(status, object) status = f_memory_delete((void **) & object) - #define f_macro_fss_object_destroy(status, object, size) status = f_memory_destroy((void **) & object, sizeof(f_fss_object), size) + #define f_macro_fss_object_delete(status, object) status = f_memory_delete((void **) & object) + #define f_macro_fss_object_destroy(status, object, length) status = f_memory_destroy((void **) & object, sizeof(f_fss_object), length) + + #define f_macro_fss_object_delete_simple(object) f_memory_delete((void **) & object) + #define f_macro_fss_object_destroy_simple(object, length) f_memory_destroy((void **) & object, sizeof(f_fss_object), length) #define f_macro_fss_object_resize(status, object, old_length, new_length) status = f_memory_resize((void **) & object, sizeof(f_fss_object), old_length, new_length) @@ -206,9 +216,12 @@ extern "C" { #define f_macro_fss_objects_new(status, objects, length) f_macro_memory_structure_new(status, objects, f_fss_object, length) - #define f_macro_fss_objects_delete(status, objects) f_macro_memory_structure_delete(status, objects, f_fss_object) + #define f_macro_fss_objects_delete(status, objects) f_macro_memory_structure_delete(status, objects, f_fss_object) #define f_macro_fss_objects_destroy(status, objects) f_macro_memory_structure_destroy(status, objects, f_fss_object) + #define f_macro_fss_objects_delete_simple(objects) f_macro_memory_structure_delete_simple(objects, f_fss_object) + #define f_macro_fss_objects_destroy_simple(objects) f_macro_memory_structure_destroy_simple(objects, f_fss_object) + #define f_macro_fss_objects_resize(status, objects, new_length) f_macro_memory_structure_resize(status, objects, f_fss_object, new_length) #define f_macro_fss_objects_adjust(status, objects, new_length) f_macro_memory_structure_destroy(status, objects, f_fss_object, new_length) #endif // _di_fss_objects_ @@ -238,9 +251,12 @@ extern "C" { #define f_macro_fss_content_new(status, content, length) f_macro_memory_structure_new(status, content, f_string_location, length) - #define f_macro_fss_content_delete(status, content) f_macro_memory_structure_delete(status, content, f_string_location) + #define f_macro_fss_content_delete(status, content) f_macro_memory_structure_delete(status, content, f_string_location) #define f_macro_fss_content_destroy(status, content) f_macro_memory_structure_destroy(status, content, f_string_location) + #define f_macro_fss_content_delete_simple(content) f_macro_memory_structure_delete_simple(content, f_string_location) + #define f_macro_fss_content_destroy_simple(content) f_macro_memory_structure_destroy_simple(content, f_string_location) + #define f_macro_fss_content_resize(status, content, new_length) f_macro_memory_structure_resize(status, content, f_string_location, new_length) #define f_macro_fss_content_adjust(status, content, new_length) f_macro_memory_structure_adjust(status, content, f_string_location, new_length) #endif // _di_fss_content_ @@ -266,9 +282,12 @@ extern "C" { #define f_macro_fss_contents_new(status, contents, length) f_macro_memory_structures_delete(status, contents, f_fss_content, length) - #define f_macro_fss_contents_delete(status, contents) f_macro_memory_structures_delete(status, contents, f_fss_content) + #define f_macro_fss_contents_delete(status, contents) f_macro_memory_structures_delete(status, contents, f_fss_content) #define f_macro_fss_contents_destroy(status, contents) f_macro_memory_structures_destroy(status, contents, f_fss_content) + #define f_macro_fss_contents_delete_simple(contents) f_macro_memory_structures_delete_simple(contents, f_fss_content) + #define f_macro_fss_contents_destroy_simple(contents) f_macro_memory_structures_destroy_simple(contents, f_fss_content) + #define f_macro_fss_contents_resize(status, contents, new_length) f_macro_memory_structures_resize(status, contents, f_fss_content, new_length, f_array_length) #define f_macro_fss_contents_adjust(status, contents, new_length) f_macro_memory_structures_resize(status, contents, f_fss_content, new_length, f_array_length) #endif // _di_f_fss_contents_ @@ -352,6 +371,28 @@ extern "C" { } /** + * Delete a fss content child. + * + * content_child: the f_fss_content_child structure to operate on. + */ + #define f_macro_fss_content_child_delete_simple(content_child) \ + f_macro_fss_content_delete_simple(content_child.content); \ + content_child.object.start = 1; \ + content_child.object.stop = 0; \ + content_child.parent = 0; + + /** + * Destroy a fss content child. + * + * content_child: the f_fss_content_child structure to operate on. + */ + #define f_macro_fss_content_child_destroy_simple(content_child) \ + f_macro_fss_content_destroy_simple(content_child.content); \ + content_child.object.start = 1; \ + content_child.object.stop = 0; \ + content_child.parent = 0; + + /** * Resize a fss content child. * * status: the status to return. @@ -398,7 +439,7 @@ extern "C" { * } * * range: A location range representing the full start/stop locations of the entire set. - * array: The array of objectm their associated content, and their associated parent. + * array: The array of object, their associated content, and their associated parent. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ @@ -455,13 +496,14 @@ extern "C" { */ #define f_macro_fss_content_childs_delete(status, content_childs) \ status = f_none; \ - while (content_childs.size > 0) { \ - f_macro_fss_content_child_delete(status, content_childs.array[content_childs.size - 1]); \ + content_childs.used = content_childs.size; \ + while (content_childs.used > 0) { \ + content_childs.used--; \ + f_macro_fss_content_child_delete(status, content_childs.array[content_childs.used]); \ if (status != f_none) break; \ - content_childs.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & content_childs.array, sizeof(f_fss_content_child), content_childs.size); \ - if (status == f_none) content_childs.used = 0; + if (status == f_none) content_childs.size = 0; /** * Destroy a fss content childs. @@ -471,13 +513,48 @@ extern "C" { */ #define f_macro_fss_content_childs_destroy(status, content_childs) \ status = f_none; \ - while (content_childs.size > 0) { \ - f_macro_fss_content_child_destroy(status, content_childs.array[content_childs.size - 1]); \ + content_childs.used = content_childs.size; \ + while (content_childs.used > 0) { \ + content_childs.used--; \ + f_macro_fss_content_child_destroy(status, content_childs.array[content_childs.used]); \ if (status != f_none) break; \ - content_childs.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & content_childs.array, sizeof(f_fss_content_child), content_childs.size); \ - if (status == f_none) content_childs.used = 0; + if (status == f_none) content_childs.size = 0; + + /** + * Delete a fss content childs. + * + * content_childs: the f_fss_content_childs structure to operate on. + */ + #define f_macro_fss_content_childs_delete_simple(content_childs) \ + content_childs.used = content_childs.size; \ + while (content_childs.used > 0) { \ + content_childs.used--; \ + f_macro_fss_content_child_delete(content_childs.array[content_childs.used]); \ + if (content_childs.used == 0) { \ + if (f_memory_delete((void **) & content_childs.array, sizeof(f_fss_content_child), content_childs.size)) { \ + content_childs.size = 0; \ + } \ + } \ + } + + /** + * Destroy a fss content childs. + * + * content_childs: the f_fss_content_childs structure to operate on. + */ + #define f_macro_fss_content_childs_destroy_simple(content_childs) \ + content_childs.used = content_childs.size; \ + while (content_childs.used > 0) { \ + content_childs.used--; \ + f_macro_fss_content_child_destroy(status, content_childs.array[content_childs.used]); \ + if (content_childs.used == 0) { \ + if (f_memory_destroy((void **) & content_childs.array, sizeof(f_fss_content_child), content_childs.size)) { \ + content_childs.size = 0; \ + } \ + } \ + } /** * Resize a fss content childs. @@ -599,13 +676,14 @@ extern "C" { */ #define f_macro_fss_content_nest_delete(status, content_nest) \ status = f_none; \ - while (content_nest.size > 0) { \ - f_macro_fss_content_childs_delete(status, content_nest.array[content_nest.size - 1]); \ + content_nest.used = content_nest.size; \ + while (content_nest.used > 0) { \ + content_nest.used--; \ + f_macro_fss_content_childs_delete(status, content_nest.array[content_nest.used]); \ if (status != f_none) break; \ - content_nest.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & content_nest.array, sizeof(f_fss_content_childs), content_nest.size); \ - if (status == f_none) content_nest.used = 0; + if (status == f_none) content_nest.size = 0; /** * Destroy a fss content nest. @@ -615,13 +693,48 @@ extern "C" { */ #define f_macro_fss_content_nest_destroy(status, content_nest) \ status = f_none; \ - while (content_nest.size > 0) { \ - f_macro_fss_content_childs_destroy(status, content_nest.array[content_nest.size - 1]); \ + content_nest.used = content_nest.size; \ + while (content_nest.used > 0) { \ + content_nest.used--; \ + f_macro_fss_content_childs_destroy(status, content_nest.array[content_nest.used]); \ if (status != f_none) break; \ - content_nest.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & content_nest.array, sizeof(f_fss_content_childs), content_nest.size); \ - if (status == f_none) content_nest.used = 0; + if (status == f_none) content_nest.size = 0; + + /** + * Delete a fss content nest. + * + * content_nest: the f_fss_content_nest structure to operate on. + */ + #define f_macro_fss_content_nest_delete_simple(content_nest) \ + content_nest.used = content_nest.size; \ + while (content_nest.used > 0) { \ + content_nest.used--; \ + f_macro_fss_content_childs_delete_simple(content_nest.array[content_nest.used]); \ + if (content_nest.used == 0) { \ + if (f_memory_delete((void **) & content_nest.array, sizeof(f_fss_content_childs), content_nest.size)) { \ + content_nest.size = 0; \ + } \ + } \ + } + + /** + * Destroy a fss content nest. + * + * content_nest: the f_fss_content_nest structure to operate on. + */ + #define f_macro_fss_content_nest_destroy_simple(content_nest) \ + content_nest.used = content_nest.size; \ + while (content_nest.used > 0) { \ + content_nest.used--; \ + f_macro_fss_content_childs_destroy_simple(content_nest.array[content_nest.used]); \ + if (content_nest.used == 0) { \ + if (f_memory_destroy((void **) & content_nest.array, sizeof(f_fss_content_childs), content_nest.size)) { \ + content_nest.size = 0; \ + } \ + } \ + } /** * Resize a fss content nest. @@ -733,15 +846,16 @@ extern "C" { * status: the status to return. * content_nests: the f_fss_content_nests structure to operate on. */ - #define f_macro_fss_content_nests_delete(status, content_nests) \ + #define f_macro_fss_content_nests_delete(content_nests) \ status = f_none; \ - while (content_nests.size > 0) { \ - f_macro_fss_content_nest_delete(status, content_nests.array[content_nests.size - 1]); \ + content_nests.used = content_nests.size; \ + while (content_nests.used > 0) { \ + content_nests.used--; \ + f_macro_fss_content_nest_delete(status, content_nests.array[content_nests.used]); \ if (status != f_none) break; \ - content_nests.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & content_nests.array, sizeof(f_fss_content_nest), content_nests.size); \ - if (status == f_none) content_nests.used = 0; + if (status == f_none) content_nests.size = 0; /** * Destroy a fss content nests. @@ -749,15 +863,50 @@ extern "C" { * status: the status to return. * content_nests: the f_fss_content_nests structure to operate on. */ - #define f_macro_fss_content_nests_destroy(status, content_nests) \ + #define f_macro_fss_content_nests_destroy(content_nests) \ status = f_none; \ - while (content_nests.size > 0) { \ - f_macro_fss_content_nest_destroy(status, content_nests.array[content_nests.size - 1]); \ + content_nests.used = content_nests.size; \ + while (content_nests.used > 0) { \ + content_nests.used--; \ + f_macro_fss_content_nest_destroy(status, content_nests.array[content_nests.used]); \ if (status != f_none) break; \ - content_nests.size--; \ } \ - if (status == f_none) status = f_memory_delete((void **) & content_nests.array, sizeof(f_fss_content_nest), content_nests.size); \ - if (status == f_none) content_nests.used = 0; + if (status == f_none) status = f_memory_destroy((void **) & content_nests.array, sizeof(f_fss_content_nest), content_nests.size); \ + if (status == f_none) content_nests.size = 0; + + /** + * Delete a fss content nests. + * + * content_nests: the f_fss_content_nests structure to operate on. + */ + #define f_macro_fss_content_nests_delete_simple(content_nests) \ + content_nests.used = content_nests.size; \ + while (content_nests.used > 0) { \ + content_nests.used--; \ + f_macro_fss_content_nest_delete_simple(content_nests.array[content_nests.used]); \ + if (content_nests.used == 0) { \ + if (f_memory_delete((void **) & content_nests.array, sizeof(f_fss_content_nest), content_nests.size)) { \ + content_nests.size = 0; \ + } \ + } \ + } + + /** + * Destroy a fss content nests. + * + * content_nests: the f_fss_content_nests structure to operate on. + */ + #define f_macro_fss_content_nests_destroy_simple(content_nests) \ + content_nests.used = content_nests.size; \ + while (content_nests.used > 0) { \ + content_nests.used--; \ + f_macro_fss_content_nest_destroy_simple(content_nests.array[content_nests.used]); \ + if (content_nests.used == 0) { \ + if (f_memory_destroy((void **) & content_nests.array, sizeof(f_fss_content_nest), content_nests.size)) { \ + content_nests.size = 0; \ + } \ + } \ + } /** * Resize a fss content nests. diff --git a/level_0/f_memory/c/memory.h b/level_0/f_memory/c/memory.h index fb11901..be48631 100644 --- a/level_0/f_memory/c/memory.h +++ b/level_0/f_memory/c/memory.h @@ -248,6 +248,34 @@ extern "C" { #endif // _di_f_macro_memory_structure_destroy_ /** + * Delete a generic memory structure. + * + * structure: the structure to operate on. + * type: the structure type. + */ +#ifndef _di_f_macro_memory_structure_delete_simple_ + #define f_macro_memory_structure_delete_simple(structure, type) \ + if (f_memory_delete((void **) & structure.array, sizeof(type), structure.size) == f_none) { \ + structure.size = 0; \ + structure.used = 0; \ + } +#endif // _di_f_macro_memory_structure_delete_simple_ + +/** + * Destroy a generic memory structure. + * + * structure: the structure to operate on. + * type: the structure type. + */ +#ifndef _di_f_macro_memory_structure_destroy_simple_ + #define f_macro_memory_structure_destroy_simple(structure, type) \ + if (f_memory_destroy((void **) & structure.array, sizeof(type), structure.size) == f_none) { \ + structure.size = 0; \ + structure.used = 0; \ + } +#endif // _di_f_macro_memory_structure_destroy_simple_ + +/** * Resize a generic memory structure. * * status: the status to return. @@ -327,13 +355,14 @@ extern "C" { #ifndef _di_f_macro_memory_structures_delete_ #define f_macro_memory_structures_delete(status, structures, type) \ status = f_none; \ - while (structures.size > 0) { \ - f_macro_memory_structure_delete(status, structures.array[structures.size - 1], type); \ + structures.used = structures.size; \ + while (structures.used > 0) { \ + structures.used--; \ + f_macro_memory_structure_delete(status, structures.array[structures.used], type); \ if (status != f_none) break; \ - structures.size--; \ } \ if (status == f_none) status = f_memory_delete((void **) & structures.array, sizeof(type), structures.size); \ - if (status == f_none) structures.used = 0; + if (status == f_none) structures.size = 0; #endif // _di_f_macro_memory_structures_delete_ /** @@ -346,16 +375,58 @@ extern "C" { #ifndef _di_f_macro_memory_structures_destroy_ #define f_macro_memory_structures_destroy(status, structures, type) \ status = f_none; \ - while (structures.size > 0) { \ - f_macro_memory_structure_destroy(status, structures.array[structures.size - 1], type); \ + structures.used = structures.size; \ + while (structures.used > 0) { \ + structures.used--; \ + f_macro_memory_structure_destroy(status, structures.array[structures.used], type); \ if (status != f_none) break; \ - structures.size--; \ } \ if (status == f_none) status = f_memory_destroy((void **) & structures.array, sizeof(type), structures.size); \ - if (status == f_none) structures.used = 0; + if (status == f_none) structures.size = 0; #endif // _di_f_macro_memory_structures_destroy_ /** + * Delete a generic memory structures. + * + * structures: the structures to operate on. + * type: the structure type.. + */ +#ifndef _di_f_macro_memory_structures_delete_simple_ + #define f_macro_memory_structures_delete_simple(structures, type) \ + structures.used = structures.size; \ + while (structures.used > 0) { \ + structures.used--; \ + f_macro_memory_structure_delete_simple(structures.array[structures.used], type); \ + if (structures.used == 0) { \ + if (f_memory_delete((void **) & structures.array, sizeof(type), structures.size)) { \ + structures.size = 0; \ + } \ + } \ + } +#endif // _di_f_macro_memory_structures_delete_simple_ + +/** + * Destroy a generic memory structures. + * + * structures: the structures to operate on. + * type: the structure type. + */ +#ifndef _di_f_macro_memory_structures_destroy_simple_ + #define f_macro_memory_structures_destroy_simple(structures, type) \ + structures.used = structures.size; \ + while (structures.used > 0) { \ + structures.used--; \ + f_macro_memory_structure_destroy_simple(structures.array[structures.used], type); \ + if (structures.used == 0) { \ + if (f_memory_destroy((void **) & structures.array, sizeof(type), structures.size)) { \ + structures.size = 0; \ + } \ + } \ + } +#endif // _di_f_macro_memory_structures_destroy_simple_ + + +/** * Resize a generic memory structures. * * status: the status to return. diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index ae553a3..68074ca 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -82,9 +82,12 @@ extern "C" { #define f_string_max_size f_type_number_size_unsigned #define f_string_initialize f_string_eos - #define f_macro_string_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_string), length) - #define f_macro_string_delete(status, string, size) status = f_memory_delete((void **) & string, sizeof(f_string), size) - #define f_macro_string_destroy(status, string, size) status = f_memory_destroy((void **) & string, sizeof(f_string), size) + #define f_macro_string_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_string), length) + #define f_macro_string_delete(status, string, length) status = f_memory_delete((void **) & string, sizeof(f_string), length) + #define f_macro_string_destroy(status, string, length) status = f_memory_destroy((void **) & string, sizeof(f_string), length) + + #define f_macro_string_delete_simple(string, length) f_memory_delete((void **) & string, sizeof(f_string), length) + #define f_macro_string_destroy_simple(string, length) f_memory_destroy((void **) & string, sizeof(f_string), length) #define f_macro_string_resize(status, string, old_length, new_length) \ status = f_memory_resize((void **) & string, sizeof(f_string), old_length, new_length) @@ -98,9 +101,12 @@ extern "C" { #define f_string_length_printf string_format_long_integer - #define f_macro_string_length_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_string_length), length) - #define f_macro_string_length_delete(status, string, length) status = f_memory_delete((void **) & string, sizeof(f_string_length), length) - #define f_macro_string_length_destroy(status, string, size) status = f_memory_destroy((f_void_P *) & string, sizeof(f_string_length), size) + #define f_macro_string_length_new(status, string, length) status = f_memory_new((void **) & string, sizeof(f_string_length), length) + #define f_macro_string_length_delete(status, string, length) status = f_memory_delete((void **) & string, sizeof(f_string_length), length) + #define f_macro_string_length_destroy(status, string, length) status = f_memory_destroy((f_void_P *) & string, sizeof(f_string_length), length) + + #define f_macro_string_length_delete_simple(string, length) f_memory_delete((void **) & string, sizeof(f_string_length), length) + #define f_macro_string_length_destroy_simple(string, length) f_memory_destroy((f_void_P *) & string, sizeof(f_string_length), length) #define f_macro_string_length_resize(status, length, old_length, new_length) \ status = f_memory_resize((void **) & length, sizeof(f_string_length), old_length, new_length) @@ -130,9 +136,12 @@ extern "C" { #define f_macro_string_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_string_length, length) - #define f_macro_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_string_length) + #define f_macro_string_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_string_length) #define f_macro_string_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_string_length) + #define f_macro_string_lengths_delete_simple(lengths) f_macro_memory_structure_delete_simple(lengths, f_string_length) + #define f_macro_string_lengths_destroy_simple(lengths) f_macro_memory_structure_destroy_simple(lengths, f_string_length) + #define f_macro_string_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_string_length, new_length) #define f_macro_string_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_string_length, new_length) #endif // _di_f_string_lengths_ @@ -157,9 +166,12 @@ extern "C" { #define f_string_location_initialize { 1, 0 } - #define f_macro_string_location_new(status, string_location, length) status = f_memory_new((void **) & string_location, sizeof(f_string_location), length) - #define f_macro_string_location_delete(status, string_location, size) status = f_memory_delete((void **) & string_location, sizeof(f_string_location), size) - #define f_macro_string_location_destroy(status, string_location, size) status = f_memory_destroy((void **) & string_location, sizeof(f_string_location), size) + #define f_macro_string_location_new(status, string_location, length) status = f_memory_new((void **) & string_location, sizeof(f_string_location), length) + #define f_macro_string_location_delete(status, string_location, length) status = f_memory_delete((void **) & string_location, sizeof(f_string_location), length) + #define f_macro_string_location_destroy(status, string_location, length) status = f_memory_destroy((void **) & string_location, sizeof(f_string_location), length) + + #define f_macro_string_location_delete_simple(string_location, length) f_memory_delete((void **) & string_location, sizeof(f_string_location), length) + #define f_macro_string_location_destroy_simple(string_location, length) f_memory_destroy((void **) & string_location, sizeof(f_string_location), length) #define f_macro_string_location_resize(status, string_location, old_length, new_length) \ status = f_memory_resize((void **) & string_location, sizeof(f_string_location), old_length, new_length) @@ -189,9 +201,12 @@ extern "C" { #define f_macro_string_locations_new(status, locations, length) f_macro_memory_structure_new(status, locations, f_string_location, length) - #define f_macro_string_locations_delete(status, locations) f_macro_memory_structure_delete(status, locations, f_string_location) + #define f_macro_string_locations_delete(status, locations) f_macro_memory_structure_delete(status, locations, f_string_location) #define f_macro_string_locations_destroy(status, locations) f_macro_memory_structure_destroy(status, locations, f_string_location) + #define f_macro_string_locations_delete_simple(locations) f_macro_memory_structure_delete_simple(locations, f_string_location) + #define f_macro_string_locations_destroy_simple(locations) f_macro_memory_structure_destroy_simple(locations, f_string_location) + #define f_macro_string_locations_resize(status, locations, new_length) f_macro_memory_structure_resize(status, locations, f_string_location, new_length) #define f_macro_string_locations_adjust(status, locations, new_length) f_macro_memory_structure_adjust(status, locations, f_string_location, new_length) #endif // _di_f_string_locations_ @@ -242,6 +257,16 @@ extern "C" { dynamic.used = 0; \ } + #define f_macro_string_dynamic_delete_simple(dynamic) \ + f_memory_delete((void **) & dynamic.string, sizeof(f_string), dynamic.size); \ + dynamic.size = 0; \ + dynamic.used = 0; + + #define f_macro_string_dynamic_destroy_simple(dynamic) \ + f_memory_destroy((void **) & dynamic.string, sizeof(f_string), dynamic.size); \ + dynamic.size = 0; \ + dynamic.used = 0; + #define f_macro_string_dynamic_resize(status, dynamic, new_length) \ status = f_memory_resize((void **) & dynamic.string, sizeof(f_string), dynamic.size, new_length); \ if (status == f_none) { \ @@ -291,30 +316,56 @@ extern "C" { #define f_macro_string_dynamics_delete(status, dynamics) \ status = f_none; \ - while (dynamics.size > 0) { \ - --dynamics.size; \ - f_macro_string_dynamic_destroy(status, dynamics.array[dynamics.size]); \ + dynamics.used = dynamics.size; \ + while (dynamics.used > 0) { \ + dynamics.used--; \ + f_macro_string_dynamic_delete(status, dynamics.array[dynamics.used]); \ if (status != f_none) break; \ } \ if (status == f_none) status = f_memory_delete((void **) & dynamics.array, sizeof(f_string_dynamic), dynamics.size); \ - if (status == f_none) dynamics.used = 0; + if (status == f_none) dynamics.size = 0; #define f_macro_string_dynamics_destroy(status, dynamics) \ status = f_none; \ - while (dynamics.size > 0) { \ - --dynamics.size; \ - f_macro_string_dynamic_destroy(status, dynamics.array[dynamics.size]); \ + dynamics.used = dynamics.size; \ + while (dynamics.used > 0) { \ + dynamics.used--; \ + f_macro_string_dynamic_destroy(status, dynamics.array[dynamics.used]); \ if (status != f_none) break; \ } \ if (status == f_none) status = f_memory_destroy((void **) & dynamics.array, sizeof(f_string_dynamic), dynamics.size); \ - if (status == f_none) dynamics.used = 0; + if (status == f_none) dynamics.size = 0; + + #define f_macro_string_dynamics_delete_simple(dynamics) \ + dynamics.used = dynamics.size; \ + while (dynamics.used > 0) { \ + dynamics.used--; \ + f_macro_string_dynamic_delete_simple(dynamics.array[dynamics.used]); \ + if (dynamics.used == 0) { \ + if (f_memory_delete((void **) & dynamics.array, sizeof(f_string_dynamic), dynamics.size)) { \ + dynamics.size = 0; \ + } \ + } \ + } + + #define f_macro_string_dynamics_destroy_simple(dynamics) \ + dynamics.used = dynamics.size; \ + while (dynamics.used > 0) { \ + dynamics.used--; \ + f_macro_string_dynamic_destroy_simple(dynamics.array[dynamics.used]); \ + if (dynamics.used == 0) { \ + if (f_memory_destroy((void **) & dynamics.array, sizeof(f_string_dynamic), dynamics.size)) { \ + dynamics.size = 0; \ + } \ + } \ + } #define f_macro_string_dynamics_resize(status, dynamics, new_length) \ status = f_none; \ if (new_length < dynamics.size) { \ f_string_length i = dynamics.size - new_length; \ for (; i < dynamics.size; i++) { \ - f_macro_string_dynamic_destroy(status, dynamics.array[i]); \ + f_macro_string_dynamic_delete(status, dynamics.array[i]); \ if (status != f_none) break; \ } \ } \ diff --git a/level_0/f_type/c/type_array.h b/level_0/f_type/c/type_array.h index 5a7d7f4..6b6760c 100644 --- a/level_0/f_type/c/type_array.h +++ b/level_0/f_type/c/type_array.h @@ -38,9 +38,12 @@ extern "C" { #define f_macro_array_lengths_new(status, lengths, length) f_macro_memory_structure_new(status, lengths, f_array_length, length) - #define f_macro_array_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_array_length) + #define f_macro_array_lengths_delete(status, lengths) f_macro_memory_structure_delete(status, lengths, f_array_length) #define f_macro_array_lengths_destroy(status, lengths) f_macro_memory_structure_destroy(status, lengths, f_array_length) + #define f_macro_array_lengths_delete_simple(lengths) f_macro_memory_structure_delete_simple(lengths, f_array_length) + #define f_macro_array_lengths_destroy_simple(lengths) f_macro_memory_structure_destroy_simple(lengths, f_array_length) + #define f_macro_array_lengths_resize(status, lengths, new_length) f_macro_memory_structure_resize(status, lengths, f_array_length, new_length) #define f_macro_array_lengths_adjust(status, lengths, new_length) f_macro_memory_structure_adjust(status, lengths, f_array_length, new_length) #endif // _di_f_array_lengths_ diff --git a/level_1/fl_color/c/color.h b/level_1/fl_color/c/color.h index 5caee23..51a6f3d 100644 --- a/level_1/fl_color/c/color.h +++ b/level_1/fl_color/c/color.h @@ -77,6 +77,28 @@ extern "C" { if (f_status_is_not_error(status)) f_macro_string_dynamic_destroy(status, color_context.normal); \ if (f_status_is_not_error(status)) f_macro_string_dynamic_destroy(status, color_context.normal_reset); + #define fl_macro_color_context_delete_simple(color_context) \ + f_macro_string_dynamic_delete_simple(color_context.reset); \ + f_macro_string_dynamic_delete_simple(color_context.warning); \ + f_macro_string_dynamic_delete_simple(color_context.error); \ + f_macro_string_dynamic_delete_simple(color_context.title); \ + f_macro_string_dynamic_delete_simple(color_context.notable); \ + f_macro_string_dynamic_delete_simple(color_context.important); \ + f_macro_string_dynamic_delete_simple(color_context.standout); \ + f_macro_string_dynamic_delete_simple(color_context.normal); \ + f_macro_string_dynamic_delete_simple(color_context.normal_reset); + + #define fl_macro_color_context_destroy_simple(color_context, size) \ + f_macro_string_dynamic_destroy_simple(color_context.reset); \ + f_macro_string_dynamic_destroy_simple(color_context.warning, size); \ + f_macro_string_dynamic_destroy_simple(color_context.error, size); \ + f_macro_string_dynamic_destroy_simple(color_context.title, size); \ + f_macro_string_dynamic_destroy_simple(color_context.notable, size); \ + f_macro_string_dynamic_destroy_simple(color_context.important, size); \ + f_macro_string_dynamic_destroy_simple(color_context.standout, size); \ + f_macro_string_dynamic_destroy_simple(color_context.normal); \ + f_macro_string_dynamic_destroy_simple(color_context.normal_reset); + #define fl_macro_color_context_resize(status, color_context) \ f_macro_string_dynamic_resize(status, color_context.reset, f_color_max_size + 1); \ if (f_status_is_not_error(status)) f_macro_string_dynamic_resize(status, color_context.warning, f_color_max_size + 1); \ diff --git a/level_1/fl_directory/c/directory.c b/level_1/fl_directory/c/directory.c index 75906e7..3463eb1 100644 --- a/level_1/fl_directory/c/directory.c +++ b/level_1/fl_directory/c/directory.c @@ -31,13 +31,11 @@ extern "C" { f_macro_string_dynamics_resize(status, (*names), names->size + fl_directory_default_allocation_step); if (f_status_is_error(status)) { - f_status status2 = f_none; - for (int j = i; j < length; j++) { f_memory_delete((void **) & listing[i], sizeof(char *), 1); - } + } // for - f_macro_string_dynamics_delete(status2, (*names)); + f_macro_string_dynamics_delete_simple((*names)); f_memory_delete((void **) & listing, sizeof(struct dirent *), 1); return status; @@ -47,13 +45,11 @@ extern "C" { f_macro_string_dynamic_new(status, names->array[names->used], size); if (f_status_is_error(status)) { - f_status status2 = f_none; - for (int j = i; j < length; j++) { f_memory_delete((void **) & listing[i], sizeof(char *), 1); - } + } // for - f_macro_string_dynamics_delete(status2, (*names)); + f_macro_string_dynamics_delete_simple((*names)); f_memory_delete((void **) & listing, sizeof(struct dirent *), 1); return status; diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 3485f5f..0e6b0cb 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -96,13 +96,11 @@ extern "C" { if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) { if (delimits.used >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + f_fss_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -193,13 +191,11 @@ extern "C" { if (slash_count % 2 == 0) { if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -231,11 +227,7 @@ extern "C" { fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop) - { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - } + f_macro_string_lengths_delete_simple(delimits); status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) return status; @@ -278,13 +270,11 @@ extern "C" { } else { if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -342,11 +332,7 @@ extern "C" { fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop) - { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - } + f_macro_string_lengths_delete_simple(delimits); status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) return status; @@ -361,11 +347,7 @@ extern "C" { fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, f_none_on_eos, f_none_on_stop) } else if (buffer->string[location->start] == f_string_eol) { - { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - } + f_macro_string_lengths_delete_simple(delimits); status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) return status; @@ -388,11 +370,7 @@ extern "C" { fl_macro_fss_object_return_on_overflow((*buffer), (*location), (*found), delimits, f_no_data_on_eos, f_no_data_on_stop) - { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - } + f_macro_string_lengths_delete_simple(delimits); status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) return status; diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index a6847df..825424f 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -90,13 +90,11 @@ extern "C" { location->start = first_slash; if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -289,13 +287,11 @@ extern "C" { } if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index 2361fe7..288159d 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -101,13 +101,11 @@ extern "C" { if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) { if (delimits.used >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + f_fss_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -194,13 +192,11 @@ extern "C" { location->start = first_slash; if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -272,13 +268,11 @@ extern "C" { } else { if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -418,8 +412,7 @@ extern "C" { f_macro_fss_content_resize(status, (*found), found->size + f_fss_default_allocation_step); if (f_status_is_error(status)){ - f_status allocation_status = f_none; - f_macro_string_lengths_delete(allocation_status, delimits); + f_macro_string_lengths_delete_simple(delimits); return status; } @@ -493,13 +486,11 @@ extern "C" { if (buffer->string[location->start] == f_fss_delimit_single_quote || buffer->string[location->start] == f_fss_delimit_double_quote) { if (delimits.used >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -587,13 +578,11 @@ extern "C" { if (slash_count % 2 == 0) { if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -665,13 +654,11 @@ extern "C" { } else { if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index 31e3444..96ad5d9 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -90,13 +90,11 @@ extern "C" { location->start = first_slash; if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(allocation_status, delimits); - return allocation_status; + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + return status; } } @@ -212,7 +210,7 @@ extern "C" { f_macro_string_lengths_new(status, positions_start, f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); + f_macro_string_lengths_delete_simple(delimits); return status; } @@ -229,10 +227,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -255,10 +251,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -272,10 +266,8 @@ extern "C" { slash_count++; } - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -318,10 +310,8 @@ extern "C" { } if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -329,10 +319,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -359,15 +347,13 @@ extern "C" { location->start = slash_first; if (delimits.used + (slash_count / 2) >= delimits.size) { - f_status allocation_status = f_none; + f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, delimits); - f_macro_string_lengths_delete(status, positions_start); - - return allocation_status; + return status; } } @@ -394,10 +380,8 @@ extern "C" { f_macro_string_lengths_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -419,15 +403,13 @@ extern "C" { location->start = slash_last; if (delimits.used + 1 >= delimits.size) { - f_status allocation_status = f_none; - - f_macro_string_lengths_resize(allocation_status, delimits, delimits.size + f_fss_default_allocation_step); + f_macro_string_lengths_resize(status, delimits, delimits.size + f_fss_default_allocation_step); - if (f_status_is_error(allocation_status)) { - f_macro_string_lengths_delete(status, delimits); - f_macro_string_lengths_delete(status, positions_start); + if (f_status_is_error(status)) { + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); - return allocation_status; + return status; } } @@ -445,10 +427,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -463,10 +443,8 @@ extern "C" { } if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -474,10 +452,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -497,10 +473,8 @@ extern "C" { f_macro_string_lengths_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -525,10 +499,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -548,10 +520,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -566,10 +536,8 @@ extern "C" { } if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -577,10 +545,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -598,10 +564,8 @@ extern "C" { f_macro_fss_content_nest_resize(status, (*found), found->size + f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -611,10 +575,8 @@ extern "C" { f_macro_fss_content_childs_resize(status, found->array[depth], found->array[depth].size + f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -626,10 +588,8 @@ extern "C" { f_macro_fss_content_resize(status, found->array[depth].array[position].content, found->array[depth].array[position].content.size + f_fss_default_allocation_step); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -659,10 +619,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -684,10 +642,8 @@ extern "C" { position_previous = location->start; status = fl_fss_increment_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -698,10 +654,8 @@ extern "C" { location->start = last_newline; status = fl_fss_decrement_buffer(*buffer, location, 1); if (f_status_is_error(status)) { - f_status allocation_status = f_none; - - f_macro_string_lengths_delete(allocation_status, delimits); - f_macro_string_lengths_delete(allocation_status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return status; } @@ -713,8 +667,8 @@ extern "C" { fl_macro_fss_content_nest_delimited_return_on_overflow((*buffer), (*location), (*found), delimits, positions_start, f_none_on_eos, f_none_on_stop) - f_macro_string_lengths_delete(status, delimits); - f_macro_string_lengths_delete(status, positions_start); + f_macro_string_lengths_delete_simple(delimits); + f_macro_string_lengths_delete_simple(positions_start); return fl_fss_found_content; } diff --git a/level_2/fll_execute/c/execute.c b/level_2/fll_execute/c/execute.c index 9914b40..0fc4cc9 100644 --- a/level_2/fll_execute/c/execute.c +++ b/level_2/fll_execute/c/execute.c @@ -54,13 +54,11 @@ extern "C" { f_macro_string_new(status, fixed_arguments[i + 1], arguments.array[i].used + 1); if (f_status_is_error(status)) { - f_status status2 = f_none; - - if (name_size > 0) f_macro_string_delete(status, program_name, name_size); + if (name_size > 0) f_macro_string_delete_simple(program_name, name_size); for (f_string_length j = 0; j < i; j++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[j].used + 1); - } + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[j].used + 1); + } // for return status; } @@ -78,12 +76,10 @@ extern "C" { process_id = vfork(); if (process_id < 0) { - f_status status2 = f_none; - - if (name_size > 0) f_macro_string_delete(status, program_name, name_size); + if (name_size > 0) f_macro_string_delete_simple(program_name, name_size); for (f_string_length i = 0; i < arguments.used; i++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[i].used + 1); + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[i].used + 1); } // for return f_status_set_error(f_fork_failed); @@ -100,15 +96,11 @@ extern "C" { // have the parent wait for the child process to finish waitpid(process_id, results, 0); - if (name_size > 0) f_macro_string_delete(status, program_name, name_size); + if (name_size > 0) f_macro_string_delete_simple(program_name, name_size); - { - f_status status2 = f_none; - - for (f_string_length i = 0; i < arguments.used; i++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[i].used + 1); - } // for - } + for (f_string_length i = 0; i < arguments.used; i++) { + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[i].used + 1); + } // for if (*results != 0) return f_status_set_error(f_failure); @@ -136,11 +128,9 @@ extern "C" { f_macro_string_new(status, fixed_arguments[i + 1], arguments.array[i].used + 1); if (f_status_is_error(status)) { - f_status status2 = f_none; - for (f_string_length j = 0; j < i; j++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[j].used + 1); - } + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[j].used + 1); + } // for return status; } @@ -158,10 +148,8 @@ extern "C" { process_id = vfork(); if (process_id < 0) { - f_status status2 = f_none; - for (f_string_length i = 0; i < arguments.used; i++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[i].used + 1); + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[i].used + 1); } // for return f_status_set_error(f_fork_failed); @@ -178,13 +166,9 @@ extern "C" { // have the parent wait for the child process to finish waitpid(process_id, results, 0); - { - f_status status2 = f_none; - - for (f_string_length i = 0; i < arguments.used; i++) { - f_macro_string_delete(status2, fixed_arguments[i + 1], arguments.array[i].used + 1); - } - } + for (f_string_length i = 0; i < arguments.used; i++) { + f_macro_string_delete_simple(fixed_arguments[i + 1], arguments.array[i].used + 1); + } // for if (*results != 0) return f_status_set_error(f_failure); diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 12b7491..d6365e7 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -81,7 +81,6 @@ extern "C" { #ifndef _di_fll_program_process_parameters_ f_return_status fll_program_process_parameters(const f_console_arguments arguments, f_console_parameters parameters, const f_console_parameter_ids choices, f_string_lengths *remaining, fl_color_context *context) { f_status status = f_none; - f_status allocation_status = f_none; status = f_console_parameter_process(arguments, parameters, remaining); @@ -91,6 +90,8 @@ extern "C" { // load colors unless told not to. if (decision != choices.id[0]) { + f_status allocation_status = f_none; + fl_macro_color_context_new(allocation_status, (*context)); if (f_status_is_error(allocation_status)) { diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index f3be9f3..ac446a1 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -364,15 +364,14 @@ extern "C" { #ifndef _di_byte_dump_delete_data_ f_return_status byte_dump_delete_data(byte_dump_data *data) { - f_status status = f_none; for (f_string_length i = 0; i < byte_dump_total_parameters; i++) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); } // for - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index fea6892..f740b2b 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -308,7 +308,7 @@ extern "C" { parameters.array[5].used = 0; parameters.array[6].used = 0; - f_macro_string_dynamics_delete(status, parameters); + f_macro_string_dynamics_delete_simple( parameters); firewall_delete_local_data(&local); firewall_delete_data(data); return status; @@ -542,8 +542,7 @@ extern "C" { status = firewall_buffer_rules(file_path.string, f_true, &local, data); - f_status status2 = f_none; - f_macro_string_dynamic_delete(status2, file_path); + f_macro_string_dynamic_delete_simple(file_path); } if (f_status_is_error(status)) { @@ -652,20 +651,19 @@ extern "C" { #ifndef _di_firewall_delete_data_ f_return_status firewall_delete_data(firewall_data *data) { - f_status status = f_none; f_string_length i = 0; while (i < firewall_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_dynamics_delete(status, data->chains); - f_macro_string_lengths_delete(status, data->remaining); - f_macro_string_dynamics_delete(status, data->devices); + f_macro_string_dynamics_delete_simple(data->chains); + f_macro_string_lengths_delete_simple(data->remaining); + f_macro_string_dynamics_delete_simple(data->devices); - fl_macro_color_context_delete(status, data->context); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 506e7b9..54f0fce 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -7,7 +7,6 @@ extern "C" { f_return_status firewall_perform_commands(const firewall_local_data local, const firewall_data data) { f_status status = f_none; - f_status status2 = f_none; f_string_length i = 0; f_string_dynamics arguments = f_string_dynamics_initialize; @@ -45,7 +44,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const f_macro_string_dynamic_new(status, device, data.devices.array[local.device].used); if (f_status_is_error(status)) { - f_macro_string_dynamic_delete(status2, device); + f_macro_string_dynamic_delete_simple(device); return status; } @@ -67,7 +66,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const is_ip_list = f_false; ip_list_direction = f_false; - f_macro_string_dynamic_delete(status2, ip_list); + f_macro_string_dynamic_delete_simple(ip_list); // process chain rule if (length >= firewall_chain_length && fl_string_compare(local.buffer.string + local.rule_objects.array[i].start, (f_string) firewall_chain, length, firewall_chain_length) == f_equal_to) { @@ -137,7 +136,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const invalid = f_true; } else if (length >= firewall_device_all_length && fl_string_compare(local.buffer.string + local.rule_contents.array[i].array[0].start, (f_string) firewall_device_all, length, firewall_device_all_length) == f_equal_to) { - f_macro_string_dynamic_delete(status, device); + f_macro_string_dynamic_delete_simple(device); device_all = f_true; continue; } @@ -154,7 +153,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const device.used = data.devices.array[local.device].used; } else { - f_macro_string_dynamic_delete(status, device); + f_macro_string_dynamic_delete_simple(device); } device_all = f_false; @@ -173,7 +172,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const device.used = length; } else { - f_macro_string_dynamic_delete(status, device); + f_macro_string_dynamic_delete_simple(device); } device_all = f_false; @@ -231,7 +230,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const use_protocol = f_false; } else if (length > 0) { - f_macro_string_dynamic_delete(status, protocol); + f_macro_string_dynamic_delete_simple(protocol); f_macro_string_dynamic_new(status, protocol, length); if (f_status_is_error(status)) break; @@ -319,7 +318,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const for (r = repeat; r > 0; r--) { // first add the program name - f_macro_string_dynamics_delete(status, arguments); + f_macro_string_dynamics_delete_simple(arguments); f_macro_string_dynamics_new(status, arguments, firewall_default_allocation_step); if (f_status_is_error(status)) break; @@ -335,7 +334,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const } } - f_macro_string_dynamic_delete(status, argument); + f_macro_string_dynamic_delete_simple(argument); if (f_status_is_error(status)) break; @@ -369,7 +368,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const if (argument.used > 0) { firewall_macro_append_argument_to_arguments(status, arguments, argument) if (f_status_is_error(status)) { - f_macro_string_dynamic_delete(status2, argument); + f_macro_string_dynamic_delete_simple(argument); break; } @@ -708,14 +707,14 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const if (f_status_is_error(status)) { fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory"); - f_macro_string_dynamic_delete(status2, ip_list_action); + f_macro_string_dynamic_delete_simple(ip_list_action); } else { f_string_dynamic ip_argument = f_string_dynamic_initialize; firewall_macro_append_argument_to_arguments(status, arguments, ip_list_action) if (f_status_is_error(status)) { - f_macro_string_dynamic_delete(status2, ip_argument); + f_macro_string_dynamic_delete_simple(ip_argument); break; } @@ -768,7 +767,7 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const fprintf(f_standard_error, "\n"); // remove ip_argument from arguments string. - f_macro_string_dynamic_delete(status2, arguments.array[arguments.used]); + f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); arguments.used--; break; @@ -777,31 +776,31 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling fll_execute_program()"); // remove ip_argument from arguments string. - f_macro_string_dynamic_delete(status2, arguments.array[arguments.used]); + f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); arguments.used--; break; } // remove ip_argument from arguments string. - f_macro_string_dynamic_delete(status2, arguments.array[arguments.used]); + f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); arguments.used--; } // for - f_macro_string_dynamic_delete(status2, ip_argument); + f_macro_string_dynamic_delete_simple(ip_argument); // remove ip_list_action from arguments string. - f_macro_string_dynamic_delete(status2, arguments.array[arguments.used]); + f_macro_string_dynamic_delete_simple(arguments.array[arguments.used]); arguments.used--; } } } } - f_macro_string_dynamic_delete(status2, local_buffer); - f_macro_string_dynamic_delete(status2, file_path); - f_macro_fss_objects_delete(status2, basic_objects); - f_macro_fss_contents_delete(status2, basic_contents); + f_macro_string_dynamic_delete_simple(local_buffer); + f_macro_string_dynamic_delete_simple(file_path); + f_macro_fss_objects_delete_simple(basic_objects); + f_macro_fss_contents_delete_simple(basic_contents); if (status == f_failure || status == f_invalid_parameter) break; } @@ -847,18 +846,17 @@ f_return_status firewall_perform_commands(const firewall_local_data local, const } // for } // for - f_macro_string_dynamic_delete(status2, ip_list); - f_macro_string_dynamic_delete(status2, argument); - f_macro_string_dynamics_delete(status2, arguments); - f_macro_string_dynamic_delete(status2, device); - f_macro_string_dynamic_delete(status2, protocol); + f_macro_string_dynamic_delete_simple(ip_list); + f_macro_string_dynamic_delete_simple(argument); + f_macro_string_dynamics_delete_simple(arguments); + f_macro_string_dynamic_delete_simple(device); + f_macro_string_dynamic_delete_simple(protocol); return status; } f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved, firewall_local_data *local, firewall_data *data) { f_status status = f_none; - f_status status2 = f_none; uint8_t tool = firewall_program_iptables; bool new_chain = f_false; @@ -874,7 +872,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved f_string_dynamic fixed_string = f_string_dynamic_initialize; - f_macro_array_lengths_delete(status, local->chain_ids); + f_macro_array_lengths_delete_simple(local->chain_ids); f_macro_array_lengths_new(status, local->chain_ids, local->chain_objects.used); if (f_status_is_error(status)) { @@ -890,7 +888,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved f_macro_string_dynamic_new(status, arguments.array[0], firewall_chain_create_command_length); if (f_status_is_error(status)) { - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -903,7 +901,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved if (f_status_is_error(status)) { arguments.used = 1; - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -983,7 +981,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved f_macro_string_dynamics_resize(status, data->chains, data->chains.used + firewall_default_allocation_step); if (f_status_is_error(status)) { - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -997,7 +995,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved f_macro_string_dynamic_resize(status, arguments.array[1], length); if (f_status_is_error(status)) { - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -1006,7 +1004,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved f_macro_string_dynamic_new(status, data->chains.array[data->chains.used], length); if (f_status_is_error(status)) { - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -1120,7 +1118,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling fll_execute_program()", status); } - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } } @@ -1131,7 +1129,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains *reserved i++; } // while - f_macro_string_dynamics_delete(status2, arguments); + f_macro_string_dynamics_delete_simple(arguments); return status; } @@ -1442,7 +1440,6 @@ f_return_status firewall_buffer_rules(const f_string filename, const bool option f_return_status firewall_process_rules(f_string_location *input, firewall_local_data *local, firewall_data *data) { f_status status = f_none; - f_status status2 = f_none; status = fll_fss_extended_read(&local->buffer, input, &local->rule_objects, &local->rule_contents); @@ -1462,14 +1459,14 @@ f_return_status firewall_process_rules(f_string_location *input, firewall_local_ fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } - f_macro_fss_objects_delete(status2, local->rule_objects); - f_macro_fss_contents_delete(status2, local->rule_contents); + f_macro_fss_objects_delete_simple(local->rule_objects); + f_macro_fss_contents_delete_simple(local->rule_contents); return status; } } - f_macro_fss_objects_delete(status2, local->rule_objects); - f_macro_fss_contents_delete(status2, local->rule_contents); + f_macro_fss_objects_delete_simple(local->rule_objects); + f_macro_fss_contents_delete_simple(local->rule_contents); return status; } @@ -1488,12 +1485,12 @@ f_return_status firewall_delete_local_data(firewall_local_data *local) { local->device = 0; local->chain = 0; - f_macro_string_dynamic_delete(status, local->buffer); - f_macro_array_lengths_delete(status, local->chain_ids); - f_macro_fss_objects_delete(status, local->chain_objects); - f_macro_fss_contents_delete(status, local->chain_contents); - f_macro_fss_objects_delete(status, local->rule_objects); - f_macro_fss_contents_delete(status, local->rule_contents); + f_macro_string_dynamic_delete_simple(local->buffer); + f_macro_array_lengths_delete_simple(local->chain_ids); + f_macro_fss_objects_delete_simple(local->chain_objects); + f_macro_fss_contents_delete_simple(local->chain_contents); + f_macro_fss_objects_delete_simple(local->rule_objects); + f_macro_fss_contents_delete_simple(local->rule_contents); return f_none; } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 67eb683..9fb0867 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -215,20 +215,19 @@ extern "C" { } fss_basic_list_read_depths depths = fss_basic_list_read_depths_initialize; - f_status status2 = f_none; f_string_length counter = 0; f_string_length original_size = data->file_position.total_elements; status = fss_basic_list_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (depths.used > 0 && depths.array[0].depth > 0) { + if (depths.array[0].depth > 0) { if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { fprintf(f_standard_output, "0%c", f_string_eol); return f_none; @@ -253,7 +252,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status)); - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } @@ -261,15 +260,15 @@ extern "C" { status = fss_basic_list_read_main_process_file(arguments, data, "-", depths); if (f_status_is_error(status)) { - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } // Clear buffers before continuing. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } if (data->remaining.used > 0) { @@ -282,7 +281,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } @@ -307,7 +306,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } @@ -315,19 +314,19 @@ extern "C" { status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); if (f_status_is_error(status)) { - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; } // Clear buffers before repeating the loop. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } // for } - macro_fss_basic_list_read_depths_delete(status2, depths); + macro_fss_basic_list_read_depths_delete_simple(depths); } else { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); @@ -345,17 +344,17 @@ extern "C" { f_string_length i = 0; while (i < fss_basic_list_read_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_fss_contents_delete(status, data->contents); - f_macro_fss_objects_delete(status, data->objects); - f_macro_string_dynamic_delete(status, data->buffer); - f_macro_string_lengths_delete(status, data->remaining); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); + f_macro_string_lengths_delete_simple(data->remaining); - fl_macro_color_context_delete(status, data->context); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index b282b87..2fea610 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -204,7 +204,6 @@ extern "C" { #ifndef _di_fss_basic_list_read_main_process_file_ f_return_status fss_basic_list_read_main_process_file(const f_console_arguments arguments, fss_basic_list_read_data *data, const f_string filename, const fss_basic_list_read_depths depths) { f_status status = f_none; - f_status status2 = f_none; { f_string_location input = f_string_location_initialize; @@ -251,9 +250,9 @@ extern "C" { } else if (status == f_no_data_on_stop || status == f_no_data_on_eos) { // Clear buffers, then attempt the next file. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); return f_status_set_warning(status); } @@ -295,7 +294,7 @@ extern "C" { f_string_length name_length = 0; for (f_string_length i = 0; i < data->objects.used; i++) { - name_length = data->objects.array[i].stop - data->objects.array[i].start + 1; + name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; if (name_length == argv_length) { if (fl_string_compare(data->buffer.string + data->objects.array[i].start, depths.array[0].value_name, name_length, argv_length) == f_equal_to) { diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h index 6ac9bd3..1a4f945 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.h @@ -16,8 +16,12 @@ extern "C" { * A structure of parameters applied at some depth. * * depth: the depth number in which this is to be processed at. - * parameter: the index representing the parameter enum of either the "at" parameter or the "name" parameter. - * position: the parameter position index within the argv representing the value associated with the designated parameter. + * + * index_at: position of the "--at" parameter value in the argv list, when 0 there is no parameter. + * index_name: position of the "--name" parameter value in the argv list, when 0 there is no parameter. + * + * value_at: the value of the "--at" parameter, already processed and ready to use, only when index_at > 0. + * value_name: the value of the "--name" parameter, already processed and ready to use, only when index_name > 0. */ #ifndef _di_fss_basic_list_read_depth_ typedef struct { @@ -61,9 +65,12 @@ extern "C" { #define macro_fss_basic_list_read_depths_new(status, depths, length) f_macro_memory_structure_new(status, depths, fss_basic_list_read_depth, length) - #define macro_fss_basic_list_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_list_read_depth) + #define macro_fss_basic_list_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_list_read_depth) #define macro_fss_basic_list_read_depths_destroy(status, depths) f_macro_memory_structure_destroy(status, depths, fss_basic_list_read_depth) + #define macro_fss_basic_list_read_depths_delete_simple(depths) f_macro_memory_structure_delete_simple(depths, fss_basic_list_read_depth) + #define macro_fss_basic_list_read_depths_destroy_simple(depths) f_macro_memory_structure_destroy_simple(depths, fss_basic_list_read_depth) + #define macro_fss_basic_list_read_depths_resize(status, depths, new_length) f_macro_memory_structure_resize(status, depths, fss_basic_list_read_depth, new_length) #define macro_fss_basic_list_read_depths_adjust(status, depths, new_length) f_macro_memory_structure_adjust(status, depths, fss_basic_list_read_depth, new_length) #endif // _di_fss_basic_list_read_depths_ diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 5e9de17..f986d87 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -85,9 +85,7 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } - f_status status2 = f_none; - - f_macro_string_dynamic_delete(status2, input); + f_macro_string_dynamic_delete_simple(input); fss_basic_list_write_delete_data(data); return f_status_set_error(status); } @@ -110,7 +108,7 @@ extern "C" { } } - f_macro_string_dynamic_delete(status, input); + f_macro_string_dynamic_delete_simple(input); } else if (data->parameters[fss_basic_list_write_parameter_string].result == f_console_result_additional) { f_string_dynamic input = f_string_dynamic_initialize; @@ -202,17 +200,16 @@ extern "C" { #ifndef _di_fss_basic_list_write_delete_data_ f_return_status fss_basic_list_write_delete_data(fss_basic_list_write_data *data) { - f_status status = f_none; f_string_length i = 0; while (i < fss_basic_list_write_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 21dbb09..695bd29 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -215,20 +215,19 @@ extern "C" { } fss_basic_read_depths depths = fss_basic_read_depths_initialize; - f_status status2 = f_none; f_string_length counter = 0; f_string_length original_size = data->file_position.total_elements; status = fss_basic_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (depths.used > 0 && depths.array[0].depth > 0) { + if (depths.array[0].depth > 0) { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { fprintf(f_standard_output, "0%c", f_string_eol); return f_none; @@ -253,7 +252,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status)); - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } @@ -261,15 +260,15 @@ extern "C" { status = fss_basic_read_main_process_file(arguments, data, "-", depths); if (f_status_is_error(status)) { - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } // Clear buffers before continuing. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } if (data->remaining.used > 0) { @@ -282,7 +281,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } @@ -307,7 +306,7 @@ extern "C" { if (f_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } @@ -315,19 +314,19 @@ extern "C" { status = fss_basic_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); if (f_status_is_error(status)) { - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); return status; } // Clear buffers before repeating the loop. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } // for } - macro_fss_basic_read_depths_delete(status2, depths); + macro_fss_basic_read_depths_delete_simple(depths); } else { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); @@ -345,17 +344,17 @@ extern "C" { f_string_length i = 0; while (i < fss_basic_read_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_fss_contents_delete(status, data->contents); - f_macro_fss_objects_delete(status, data->objects); - f_macro_string_dynamic_delete(status, data->buffer); - f_macro_string_lengths_delete(status, data->remaining); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); + f_macro_string_lengths_delete_simple(data->remaining); - fl_macro_color_context_delete(status, data->context); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index af081a7..15fa7fc 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -204,7 +204,6 @@ extern "C" { #ifndef _di_fss_basic_read_main_process_file_ f_return_status fss_basic_read_main_process_file(const f_console_arguments arguments, fss_basic_read_data *data, const f_string filename, const fss_basic_read_depths depths) { f_status status = f_none; - f_status status2 = f_none; { f_string_location input = f_string_location_initialize; @@ -251,9 +250,9 @@ extern "C" { } else if (status == f_no_data_on_stop || status == f_no_data_on_eos) { // Clear buffers, then attempt the next file. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); return f_status_set_warning(status); } @@ -295,7 +294,7 @@ extern "C" { f_string_length name_length = 0; for (f_string_length i = 0; i < data->objects.used; i++) { - name_length = data->objects.array[i].stop - data->objects.array[i].start + 1; + name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; if (name_length == argv_length) { if (fl_string_compare(data->buffer.string + data->objects.array[i].start, depths.array[0].value_name, name_length, argv_length) == f_equal_to) { diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.h b/level_3/fss_basic_read/c/private-fss_basic_read.h index 1a880fe..f9f2a28 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.h +++ b/level_3/fss_basic_read/c/private-fss_basic_read.h @@ -16,8 +16,12 @@ extern "C" { * A structure of parameters applied at some depth. * * depth: the depth number in which this is to be processed at. - * parameter: the index representing the parameter enum of either the "at" parameter or the "name" parameter. - * position: the parameter position index within the argv representing the value associated with the designated parameter. + * + * index_at: position of the "--at" parameter value in the argv list, when 0 there is no parameter. + * index_name: position of the "--name" parameter value in the argv list, when 0 there is no parameter. + * + * value_at: the value of the "--at" parameter, already processed and ready to use, only when index_at > 0. + * value_name: the value of the "--name" parameter, already processed and ready to use, only when index_name > 0. */ #ifndef _di_fss_basic_read_depth_ typedef struct { @@ -61,9 +65,12 @@ extern "C" { #define macro_fss_basic_read_depths_new(status, depths, length) f_macro_memory_structure_new(status, depths, fss_basic_read_depth, length) - #define macro_fss_basic_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_read_depth) + #define macro_fss_basic_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_basic_read_depth) #define macro_fss_basic_read_depths_destroy(status, depths) f_macro_memory_structure_destroy(status, depths, fss_basic_read_depth) + #define macro_fss_basic_read_depths_delete_simple(depths) f_macro_memory_structure_delete_simple(depths, fss_basic_read_depth) + #define macro_fss_basic_read_depths_destroy_simple(depths) f_macro_memory_structure_destroy_simple(depths, fss_basic_read_depth) + #define macro_fss_basic_read_depths_resize(status, depths, new_length) f_macro_memory_structure_resize(status, depths, fss_basic_read_depth, new_length) #define macro_fss_basic_read_depths_adjust(status, depths, new_length) f_macro_memory_structure_adjust(status, depths, fss_basic_read_depth, new_length) #endif // _di_fss_basic_read_depths_ diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index ec928a5..d989239 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -85,9 +85,7 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } - f_status status2 = f_none; - - f_macro_string_dynamic_delete(status2, input); + f_macro_string_dynamic_delete_simple(input); fss_basic_write_delete_data(data); return f_status_set_error(status); } @@ -110,7 +108,7 @@ extern "C" { } } - f_macro_string_dynamic_delete(status, input); + f_macro_string_dynamic_delete_simple(input); } else if (data->parameters[fss_basic_write_parameter_string].result == f_console_result_additional) { f_string_dynamic input = f_string_dynamic_initialize; @@ -206,13 +204,13 @@ extern "C" { f_string_length i = 0; while (i < fss_basic_write_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index e314a3d..b38c757 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -215,20 +215,19 @@ extern "C" { } fss_extended_read_depths depths = fss_extended_read_depths_initialize; - f_status status2 = f_none; f_string_length counter = 0; f_string_length original_size = data->file_position.total_elements; status = fss_extended_read_main_preprocess_depth(arguments, *data, &depths); if (f_status_is_error(status)) { - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } // This standard does not support nesting, so any depth greater than 0 can be predicted without processing the file. - if (depths.used > 0 && depths.array[0].depth > 0) { + if (depths.array[0].depth > 0) { if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { fprintf(f_standard_output, "0%c", f_string_eol); return f_none; @@ -253,7 +252,7 @@ extern "C" { if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "fl_file_read_fifo", "-", f_status_set_fine(status)); - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } @@ -261,15 +260,15 @@ extern "C" { status = fss_extended_read_main_process_file(arguments, data, "-", depths); if (f_status_is_error(status)) { - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } // Clear buffers before continuing. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } if (data->remaining.used > 0) { @@ -282,7 +281,7 @@ extern "C" { if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } @@ -307,7 +306,7 @@ extern "C" { if (f_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "fl_file_read", arguments.argv[data->remaining.array[counter]], f_status_set_fine(status)); - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } @@ -315,19 +314,19 @@ extern "C" { status = fss_extended_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); if (f_status_is_error(status)) { - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); return status; } // Clear buffers before repeating the loop. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); } // for } - macro_fss_extended_read_depths_delete(status2, depths); + macro_fss_extended_read_depths_delete_simple(depths); } else { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "ERROR: you failed to specify one or more files."); @@ -345,17 +344,17 @@ extern "C" { f_string_length i = 0; while (i < fss_extended_read_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_fss_contents_delete(status, data->contents); - f_macro_fss_objects_delete(status, data->objects); - f_macro_string_dynamic_delete(status, data->buffer); - f_macro_string_lengths_delete(status, data->remaining); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); + f_macro_string_lengths_delete_simple(data->remaining); - fl_macro_color_context_delete(status, data->context); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 6b09eaf..a72b89a 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -204,7 +204,6 @@ extern "C" { #ifndef _di_fss_extended_read_main_process_file_ f_return_status fss_extended_read_main_process_file(const f_console_arguments arguments, fss_extended_read_data *data, const f_string filename, const fss_extended_read_depths depths) { f_status status = f_none; - f_status status2 = f_none; { f_string_location input = f_string_location_initialize; @@ -251,9 +250,9 @@ extern "C" { } else if (status == f_no_data_on_stop || status == f_no_data_on_eos) { // Clear buffers, then attempt the next file. - f_macro_fss_contents_delete(status2, data->contents); - f_macro_fss_objects_delete(status2, data->objects); - f_macro_string_dynamic_delete(status2, data->buffer); + f_macro_fss_contents_delete_simple(data->contents); + f_macro_fss_objects_delete_simple(data->objects); + f_macro_string_dynamic_delete_simple(data->buffer); return f_status_set_warning(status); } @@ -290,7 +289,7 @@ extern "C" { f_string_length name_length = 0; for (f_string_length i = 0; i < data->objects.used; i++) { - name_length = data->objects.array[i].stop - data->objects.array[i].start + 1; + name_length = (data->objects.array[i].stop - data->objects.array[i].start) + 1; if (name_length == argv_length) { if (fl_string_compare(data->buffer.string + data->objects.array[i].start, depths.array[0].value_name, name_length, argv_length) == f_equal_to) { diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.h b/level_3/fss_extended_read/c/private-fss_extended_read.h index 6d9bf0b..c48154c 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.h +++ b/level_3/fss_extended_read/c/private-fss_extended_read.h @@ -16,8 +16,12 @@ extern "C" { * A structure of parameters applied at some depth. * * depth: the depth number in which this is to be processed at. - * parameter: the index representing the parameter enum of either the "at" parameter or the "name" parameter. - * position: the parameter position index within the argv representing the value associated with the designated parameter. + * + * index_at: position of the "--at" parameter value in the argv list, when 0 there is no parameter. + * index_name: position of the "--name" parameter value in the argv list, when 0 there is no parameter. + * + * value_at: the value of the "--at" parameter, already processed and ready to use, only when index_at > 0. + * value_name: the value of the "--name" parameter, already processed and ready to use, only when index_name > 0. */ #ifndef _di_fss_extended_read_depth_ typedef struct { @@ -61,9 +65,12 @@ extern "C" { #define macro_fss_extended_read_depths_new(status, depths, length) f_macro_memory_structure_new(status, depths, fss_extended_read_depth, length) - #define macro_fss_extended_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_extended_read_depth) + #define macro_fss_extended_read_depths_delete(status, depths) f_macro_memory_structure_delete(status, depths, fss_extended_read_depth) #define macro_fss_extended_read_depths_destroy(status, depths) f_macro_memory_structure_destroy(status, depths, fss_extended_read_depth) + #define macro_fss_extended_read_depths_delete_simple(depths) f_macro_memory_structure_delete_simple(depths, fss_extended_read_depth) + #define macro_fss_extended_read_depths_destroy_simple(depths) f_macro_memory_structure_destroy_simple(depths, fss_extended_read_depth) + #define macro_fss_extended_read_depths_resize(status, depths, new_length) f_macro_memory_structure_resize(status, depths, fss_extended_read_depth, new_length) #define macro_fss_extended_read_depths_adjust(status, depths, new_length) f_macro_memory_structure_adjust(status, depths, fss_extended_read_depth, new_length) #endif // _di_fss_extended_read_depths_ diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 1e6c374..6bf58c9 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -112,9 +112,7 @@ extern "C" { fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status); } - f_status status2 = f_none; - - f_macro_string_dynamic_delete(status2, input); + f_macro_string_dynamic_delete_simple(input); fss_extended_write_delete_data(data); return f_status_set_error(status); } @@ -150,7 +148,7 @@ extern "C" { } } - f_macro_string_dynamic_delete(status, input); + f_macro_string_dynamic_delete_simple(input); } else if (data->parameters[fss_extended_write_parameter_string].result == f_console_result_additional) { f_string_dynamic input = f_string_dynamic_initialize; @@ -271,13 +269,13 @@ extern "C" { f_string_length i = 0; while (i < fss_extended_write_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index 5f998d2..c469227 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -152,17 +152,16 @@ extern "C" { #ifndef _di_fss_status_code_delete_data_ f_return_status fss_status_code_delete_data(fss_status_code_data *data) { - f_status status = f_none; f_string_length i = 0; while (i < fss_status_code_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index 61df077..fc05fda 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -96,7 +96,6 @@ #ifndef _di_init_rules_process_main_ f_return_status init_rules_process_main(const init_data data, const f_string filename, f_string_dynamic *buffer, f_fss_objects *objects, f_fss_contents *contents) { f_status status = f_none; - f_status status2 = f_none; // @todo: resume replacing code below. status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents); @@ -115,14 +114,14 @@ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } - f_macro_fss_objects_delete(status2, local->rule_objects); - f_macro_fss_contents_delete(status2, local->rule_contents); + f_macro_fss_objects_delete_simple(local->rule_objects); + f_macro_fss_contents_delete_simple(local->rule_contents); return f_status_set_error(status); } } - f_macro_fss_objects_delete(status2, local->rule_objects); - f_macro_fss_contents_delete(status2, local->rule_contents); + f_macro_fss_objects_delete_simple(local->rule_objects); + f_macro_fss_contents_delete_simple(local->rule_contents); return status; } #endif // _init_rules_process_main_ @@ -542,7 +541,6 @@ /* f_status status = f_none; - f_status status2 = f_none; status = fll_fss_extended_read(buffer, location, objects, contents); @@ -561,8 +559,8 @@ fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling firewall_perform_commands().", status); } - f_macro_fss_objects_delete(status2, (*rule_objects)); - f_macro_fss_contents_delete(status2, (*rule_contents)); + f_macro_fss_objects_delete_simple((*rule_objects)); + f_macro_fss_contents_delete_simple((*rule_contents)); return f_status_set_error(status); } } @@ -575,8 +573,8 @@ } } - f_macro_fss_objects_delete(status2, (*rule_objects)); - f_macro_fss_contents_delete(status2, (*rule_contents)); + f_macro_fss_objects_delete_simple((*rule_objects)); + f_macro_fss_contents_delete_simple((*rule_contents)); */ /* f_macro_string_dynamic_delete(buffer); diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index 4d66b0a..6bdb57f 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -156,13 +156,13 @@ extern "C" { f_string_length i = 0; while (i < status_code_total_parameters) { - f_macro_string_lengths_delete(status, data->parameters[i].locations); - f_macro_string_lengths_delete(status, data->parameters[i].additional); + f_macro_string_lengths_delete_simple(data->parameters[i].locations); + f_macro_string_lengths_delete_simple(data->parameters[i].additional); i++; } // while - f_macro_string_lengths_delete(status, data->remaining); - fl_macro_color_context_delete(status, data->context); + f_macro_string_lengths_delete_simple(data->remaining); + fl_macro_color_context_delete_simple(data->context); return f_none; } -- 1.8.3.1