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

level_3/fss_identify/c/common.c
level_3/fss_identify/c/common.h
level_3/fss_identify/c/fss_identify.c
level_3/fss_identify/c/fss_identify.h
level_3/fss_identify/c/main.c

index 6beb761acf702d5e4dbc113d9acb862535a76093..2ab2fa7e0201bf706ea76668b4a6877859ac63e4 100644 (file)
@@ -27,13 +27,6 @@ extern "C" {
   const f_string_static_t fss_identify_long_total_s = macro_f_string_static_t_initialize(FSS_IDENTIFY_long_total_s, 0, FSS_IDENTIFY_long_total_s_length);
 #endif // _di_fss_identify_parameters_
 
-#ifndef _di_fss_identify_main_delete_
-  f_status_t fss_identify_main_delete(fll_program_data_t * const main) {
-
-    return fll_program_data_delete(main);
-  }
-#endif // _di_fss_identify_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index ce0584cd320ad97c2187b531acf138537505e48b..3c98aa27e1f0eb3dfaa03662685145ae88490189 100644 (file)
@@ -145,25 +145,6 @@ extern "C" {
   #define fss_identify_total_parameters_d 14
 #endif // _di_fss_identify_parameters_
 
-/**
- * Deallocate main.
- *
- * Be sure to call this after executing fss_identify_main().
- *
- * @param main
- *   The main program data.
- *
- * @return
- *   F_none on success.
- *
- *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_identify_main()
- */
-#ifndef _di_fss_identify_main_delete_
-  extern f_status_t fss_identify_main_delete(fll_program_data_t * const main);
-#endif // _di_fss_identify_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index e6a8211719280bff46e76fe6b7aeab0873f6cf8d..51b225f007b42642261bbbf1ae7bf03c7aaced92 100644 (file)
@@ -62,10 +62,6 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    f_console_parameter_t parameters[] = fss_identify_console_parameter_t_initialize;
-    main->parameters.array = parameters;
-    main->parameters.used = fss_identify_total_parameters_d;
-
     {
       f_console_parameter_id_t ids[3] = { fss_identify_parameter_no_color_e, fss_identify_parameter_light_e, fss_identify_parameter_dark_e };
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
@@ -98,8 +94,6 @@ extern "C" {
           fll_print_dynamic_raw(f_string_eol_s, main->error.to.stream);
         }
 
-        fss_identify_main_delete(main);
-
         return F_status_set_error(status);
       }
     }
@@ -111,12 +105,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_identify_main_delete(main);
-
-        return status;
-      }
+      if (F_status_is_error(status)) return status;
 
       if (choice == fss_identify_parameter_verbosity_quiet_e) {
         main->output.verbosity = f_console_verbosity_quiet_e;
@@ -145,16 +134,12 @@ extern "C" {
     if (main->parameters.array[fss_identify_parameter_help_e].result == f_console_result_found_e) {
       fss_identify_print_help(main->output.to, main->context);
 
-      fss_identify_main_delete(main);
-
       return F_none;
     }
 
     if (main->parameters.array[fss_identify_parameter_version_e].result == f_console_result_found_e) {
       fll_program_print_version(main->output.to, fss_identify_program_version_s);
 
-      fss_identify_main_delete(main);
-
       return F_none;
     }
 
@@ -359,7 +344,6 @@ extern "C" {
     }
 
     fss_identify_data_delete(&data);
-    fss_identify_main_delete(main);
 
     return status;
   }
index 61017444b723d9e36872608b9e8ddfe6ea6eacdf..19d96fa5657940d2453fdda6a987f91c37800fd5 100644 (file)
@@ -70,8 +70,6 @@ extern "C" {
 /**
  * Execute main program.
  *
- * Be sure to call fss_identify_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
@@ -89,8 +87,6 @@ extern "C" {
  *   F_none on success.
  *
  *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_identify_main_delete()
  */
 #ifndef _di_fss_identify_main_
   extern f_status_t fss_identify_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
index a622ece4011d0a1ede886e46d74d39204ac853a0..d2b21977f34a1e14ab325a67c7e0bb9c1056fcec 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_identify_console_parameter_t_initialize;
+  data.parameters.array = parameters;
+  data.parameters.used = fss_identify_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_identify_main(&data, &arguments);
 
+  fll_program_data_delete(&data);
+
   fll_program_standard_setdown(&data.signal);
 
   if (F_status_is_error(status)) return 1;