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

level_3/fss_payload_read/c/common.c
level_3/fss_payload_read/c/common.h
level_3/fss_payload_read/c/fss_payload_read.c
level_3/fss_payload_read/c/fss_payload_read.h
level_3/fss_payload_read/c/main.c

index 1f472c2456dfa12902f59e2d8fb3fef822564ac1..e2eaeff52682b6ae3b7ff56252d8071b5494967a 100644 (file)
@@ -52,13 +52,6 @@ extern "C" {
   const f_string_static_t fss_payload_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_READ_delimit_mode_name_lesser_s, 0, FSS_PAYLOAD_READ_delimit_mode_name_lesser_s_length);
 #endif // _di_fss_payload_read_delimit_mode_
 
-#ifndef _di_fss_payload_read_main_delete_
-  f_status_t fss_payload_read_main_delete(fll_program_data_t * const main) {
-
-    return fll_program_data_delete(main);
-  }
-#endif // _di_fss_payload_read_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 0811adb6007f37547ee6f3d0fef82c8ffbf09966..b7364be621f4a134674ec102a60c2f6492284348 100644 (file)
@@ -280,25 +280,6 @@ extern "C" {
   };
 #endif // _di_fss_payload_read_delimit_modes_
 
-/**
- * Deallocate main.
- *
- * Be sure to call this after executing fss_payload_read_main().
- *
- * @param main
- *   The main program data.
- *
- * @return
- *   F_none on success.
- *
- *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_payload_read_main()
- */
-#ifndef _di_fss_payload_read_main_delete_
-  extern f_status_t fss_payload_read_main_delete(fll_program_data_t * const main);
-#endif // _di_fss_payload_read_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index b04032a6d7fcb22e274a27081c20889fd681263f..04ef63f0a4cee8059b160ceeb7e43c45de4e31eb 100644 (file)
@@ -141,10 +141,6 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    f_console_parameter_t parameters[] = fss_payload_read_console_parameter_t_initialize;
-    main->parameters.array = parameters;
-    main->parameters.used = fss_payload_read_total_parameters_d;
-
     {
       f_console_parameter_id_t ids[3] = { fss_payload_read_parameter_no_color_e, fss_payload_read_parameter_light_e, fss_payload_read_parameter_dark_e };
       const f_console_parameter_ids_t choices = { ids, 3 };
@@ -171,11 +167,7 @@ extern "C" {
         fll_program_parameter_process_empty(&main->context, sets);
       }
 
-      if (F_status_is_error(status)) {
-        fss_payload_read_main_delete(main);
-
-        return F_status_set_error(status);
-      }
+      if (F_status_is_error(status)) return F_status_set_error(status);
     }
 
     // Identify priority of verbosity related parameters.
@@ -186,11 +178,7 @@ extern "C" {
 
       status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
 
-      if (F_status_is_error(status)) {
-        fss_payload_read_main_delete(main);
-
-        return status;
-      }
+      if (F_status_is_error(status)) return status;
 
       if (choice == fss_payload_read_parameter_verbosity_quiet_e) {
         main->output.verbosity = f_console_verbosity_quiet_e;
@@ -219,16 +207,12 @@ extern "C" {
     if (main->parameters.array[fss_payload_read_parameter_help_e].result == f_console_result_found_e) {
       fss_payload_read_print_help(main->output.to, main->context);
 
-      fss_payload_read_main_delete(main);
-
       return status;
     }
 
     if (main->parameters.array[fss_payload_read_parameter_version_e].result == f_console_result_found_e) {
       fll_program_print_version(main->output.to, fss_payload_read_program_version_s);
 
-      fss_payload_read_main_delete(main);
-
       return status;
     }
 
@@ -531,7 +515,6 @@ extern "C" {
           }
 
           fss_payload_read_data_delete_simple(&data);
-          fss_payload_read_main_delete(main);
 
           return F_none;
         }
@@ -680,7 +663,6 @@ extern "C" {
     }
 
     fss_payload_read_data_delete_simple(&data);
-    fss_payload_read_main_delete(main);
 
     return status;
   }
index 4f5caa3f7a992ab4dc4726537f8f6cfa3012c6f7..5c1a396cb29281f1381e9bbfc4bc2d39305dd8ab 100644 (file)
@@ -73,8 +73,6 @@ extern "C" {
 /**
  * Execute main program.
  *
- * Be sure to call fss_payload_read_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
@@ -92,8 +90,6 @@ extern "C" {
  *   F_none on success.
  *
  *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_payload_read_main_delete()
  */
 #ifndef _di_fss_payload_read_main_
   extern f_status_t fss_payload_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
index 9403fb01df7382467add6117656c320cecda3f4b..db7a2da9b19baf5beb73bc320ed3ae2dd2de6a1e 100644 (file)
@@ -5,6 +5,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   f_console_arguments_t arguments = { argc, argv };
   fll_program_data_t data = fll_program_data_t_initialize;
 
+  f_console_parameter_t parameters[] = fss_payload_read_console_parameter_t_initialize;
+  data.parameters.array = parameters;
+  data.parameters.used = fss_payload_read_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_payload_read_main(&data, &arguments);
 
+  fll_program_data_delete(&data);
+
   fll_program_standard_setdown(&data.signal);
 
   if (F_status_is_error(status)) return 1;