]> Kevux Git Server - fll/commitdiff
Update: Move the program data into the main for fss_extended_list_write.
authorKevin Day <thekevinday@gmail.com>
Wed, 30 Mar 2022 04:09:26 +0000 (23:09 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 30 Mar 2022 04:09:26 +0000 (23:09 -0500)
Move parameter initialization and deallocation for FLL program data into main.c.

level_3/fss_extended_list_write/c/common.h
level_3/fss_extended_list_write/c/fss_extended_list_write.c
level_3/fss_extended_list_write/c/fss_extended_list_write.h
level_3/fss_extended_list_write/c/main.c

index e14638947704eaa5e7884e61d42434fc7e86609f..594f2fef3b65a4bdc33be5fe1f9a545aad84e448 100644 (file)
@@ -204,8 +204,6 @@ extern "C" {
 /**
  * Deallocate main.
  *
- * Be sure to call this after executing fss_extended_list_write_main().
- *
  * @param main
  *   The main program data.
  *
index 16cd23c489bff049529835a1dfc4299f6087e2d1..71621e246894bbc1e583dc4b63e7660cb7a84bb0 100644 (file)
@@ -64,10 +64,6 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    f_console_parameter_t parameters[] = fss_extended_list_write_console_parameter_t_initialize;
-    main->parameters.array = parameters;
-    main->parameters.used = fss_extended_list_write_total_parameters_d;
-
     {
       f_console_parameter_id_t ids[3] = { fss_extended_list_write_parameter_no_color_e, fss_extended_list_write_parameter_light_e, fss_extended_list_write_parameter_dark_e };
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
@@ -94,11 +90,7 @@ extern "C" {
         fll_program_parameter_process_empty(&main->context, sets);
       }
 
-      if (F_status_is_error(status)) {
-        fss_extended_list_write_main_delete(main);
-
-        return F_status_set_error(status);
-      }
+      if (F_status_is_error(status)) return status;
     }
 
     // Identify priority of verbosity related parameters.
@@ -108,12 +100,7 @@ extern "C" {
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 4);
 
       status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
-
-      if (F_status_is_error(status)) {
-        fss_extended_list_write_main_delete(main);
-
-        return status;
-      }
+      if (F_status_is_error(status)) return status;
 
       if (choice == fss_extended_list_write_parameter_verbosity_quiet_e) {
         main->output.verbosity = f_console_verbosity_quiet_e;
@@ -144,16 +131,12 @@ extern "C" {
     if (main->parameters.array[fss_extended_list_write_parameter_help_e].result == f_console_result_found_e) {
       fss_extended_list_write_print_help(main->output.to, main->context);
 
-      fss_extended_list_write_main_delete(main);
-
       return status;
     }
 
     if (main->parameters.array[fss_extended_list_write_parameter_version_e].result == f_console_result_found_e) {
       fll_program_print_version(main->output.to, fss_extended_list_write_program_version_s);
 
-      fss_extended_list_write_main_delete(main);
-
       return status;
     }
 
@@ -519,7 +502,6 @@ extern "C" {
     }
 
     f_string_dynamic_resize(0, &buffer);
-    fss_extended_list_write_main_delete(main);
 
     return status;
   }
index d8e3e91c615d1af66cc10bcd67e4247915376fc0..2934f686abd91510b155ffe0940d630425bd22e8 100644 (file)
@@ -65,8 +65,6 @@ extern "C" {
 /**
  * Execute main program.
  *
- * Be sure to call fss_extended_list_write_main_delete() after executing this.
- *
  * If main.signal is non-zero, then this blocks and handles the following signals:
  *   - F_signal_abort
  *   - F_signal_broken_pipe
@@ -84,8 +82,6 @@ extern "C" {
  *   F_none on success.
  *
  *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_extended_list_write_main_delete()
  */
 #ifndef _di_fss_extended_list_write_main_
   extern f_status_t fss_extended_list_write_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
index 956520b614ad6550090c3b5ae8afcd9b6349a29b..3a959ab46cbcb839d3b67c78c85fbe0c7124c805 100644 (file)
@@ -5,6 +5,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp);
   fll_program_data_t data = fll_program_data_t_initialize;
 
+  f_console_parameter_t parameters[] = fss_extended_list_write_console_parameter_t_initialize;
+  data.parameters.array = parameters;
+  data.parameters.used = fss_extended_list_write_total_parameters_d;
+
   if (f_pipe_input_exists()) {
     data.process_pipe = F_true;
   }
@@ -13,6 +17,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   const f_status_t status = fss_extended_list_write_main(&data, &arguments);
 
+  fll_program_data_delete(&data);
+
   fll_program_standard_setdown(&data.signal);
 
   if (F_status_is_error(status)) return 1;