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

level_3/fss_payload_write/c/common.c
level_3/fss_payload_write/c/common.h
level_3/fss_payload_write/c/fss_payload_write.c
level_3/fss_payload_write/c/fss_payload_write.h
level_3/fss_payload_write/c/main.c

index 50e369a3e25b02581f96e9530ace6925da787fef..6d321da50565dd0df4af100c6ef0c91e9b972a85 100644 (file)
@@ -32,13 +32,6 @@ extern "C" {
   const f_string_static_t fss_payload_write_long_trim_s = macro_f_string_static_t_initialize(FSS_PAYLOAD_WRITE_long_trim_s, 0, FSS_PAYLOAD_WRITE_long_trim_s_length);
 #endif // _di_fss_payload_write_parameters_
 
-#ifndef _di_fss_payload_write_main_delete_
-  f_status_t fss_payload_write_main_delete(fll_program_data_t * const main) {
-
-    return fll_program_data_delete(main);
-  }
-#endif // _di_fss_payload_write_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index bebe0ac88a8147ea89c9dbcbd93e7c11194b5a9d..68c7551ca6bf3dc5cab4d639511f7bc9c127a807 100644 (file)
@@ -189,25 +189,6 @@ extern "C" {
   #define fss_payload_write_total_parameters_d 18
 #endif // _di_fss_payload_write_parameters_
 
-/**
- * Deallocate main.
- *
- * Be sure to call this after executing fss_payload_write_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_write_main()
- */
-#ifndef _di_fss_payload_write_main_delete_
-  extern f_status_t fss_payload_write_main_delete(fll_program_data_t * const main);
-#endif // _di_fss_payload_write_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index d35c01ca40cf0dc6e197726e24ecc9822f317086..1854114e055951eb5658aa5cbcb1774a5d6a12d4 100644 (file)
@@ -70,10 +70,6 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    f_console_parameter_t parameters[] = fss_payload_write_console_parameter_t_initialize;
-    main->parameters.array = parameters;
-    main->parameters.used = fss_payload_write_total_parameters_d;
-
     {
       f_console_parameter_id_t ids[3] = { fss_payload_write_parameter_no_color_e, fss_payload_write_parameter_light_e, fss_payload_write_parameter_dark_e };
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
@@ -100,10 +96,7 @@ extern "C" {
         fll_program_parameter_process_empty(&main->context, sets);
       }
 
-      if (F_status_is_error(status)) {
-        fss_payload_write_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.
@@ -114,10 +107,7 @@ extern "C" {
 
       status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
 
-      if (F_status_is_error(status)) {
-        fss_payload_write_main_delete(main);
-        return status;
-      }
+      if (F_status_is_error(status)) return status;
 
       if (choice == fss_payload_write_parameter_verbosity_quiet_e) {
         main->output.verbosity = f_console_verbosity_quiet_e;
@@ -148,14 +138,12 @@ extern "C" {
     if (main->parameters.array[fss_payload_write_parameter_help_e].result == f_console_result_found_e) {
       fss_payload_write_print_help(main->output.to, main->context);
 
-      fss_payload_write_main_delete(main);
       return status;
     }
 
     if (main->parameters.array[fss_payload_write_parameter_version_e].result == f_console_result_found_e) {
       fll_program_print_version(main->output.to, fss_payload_write_program_version_s);
 
-      fss_payload_write_main_delete(main);
       return status;
     }
 
@@ -517,7 +505,6 @@ extern "C" {
     }
 
     f_string_dynamic_resize(0, &buffer);
-    fss_payload_write_main_delete(main);
 
     return status;
   }
index 1679a62095778ccacff6906778ca70bcd2ca2d3d..c0b2a270728ff1ba34b8b56fb484df05c3f4d77d 100644 (file)
@@ -65,8 +65,6 @@ extern "C" {
 /**
  * Execute main program.
  *
- * Be sure to call fss_payload_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_payload_write_main_delete()
  */
 #ifndef _di_fss_payload_write_main_
   extern f_status_t fss_payload_write_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
index 6271b613f2791873396991c5ecef603d5a60e625..cbb903cac30fb2412ae37895ae6aad39e10e0fa3 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_payload_write_console_parameter_t_initialize;
+  data.parameters.array = parameters;
+  data.parameters.used = fss_payload_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_payload_write_main(&data, &arguments);
 
+  fll_program_data_delete(&data);
+
   fll_program_standard_setdown(&data.signal);
 
   if (F_status_is_error(status)) return 1;