Remove various empty or useless functions

In particular remove init()/destroy() functions that do nothing, or
destroy functions that only free memory.
This commit is contained in:
ridiculousfish 2018-02-10 17:21:55 -08:00
parent 3a45cad12e
commit ba7b8a9584
13 changed files with 3 additions and 49 deletions

View file

@ -489,9 +489,6 @@ void builtin_init() {
} }
} }
/// Destroy builtin data.
void builtin_destroy() {}
/// Is there a builtin command with the given name? /// Is there a builtin command with the given name?
bool builtin_exists(const wcstring &cmd) { return static_cast<bool>(builtin_lookup(cmd)); } bool builtin_exists(const wcstring &cmd) { return static_cast<bool>(builtin_lookup(cmd)); }

View file

@ -76,7 +76,6 @@ enum { COMMAND_NOT_BUILTIN, BUILTIN_REGULAR, BUILTIN_FUNCTION };
#define FG_MSG _(L"Send job %d, '%ls' to foreground\n") #define FG_MSG _(L"Send job %d, '%ls' to foreground\n")
void builtin_init(); void builtin_init();
void builtin_destroy();
bool builtin_exists(const wcstring &cmd); bool builtin_exists(const wcstring &cmd);
int builtin_run(parser_t &parser, const wchar_t *const *argv, io_streams_t &streams); int builtin_run(parser_t &parser, const wchar_t *const *argv, io_streams_t &streams);

View file

@ -448,10 +448,6 @@ void event_fire(const event_t *event) {
} }
} }
void event_init() {}
void event_destroy() { s_event_handlers.clear(); }
void event_fire_generic(const wchar_t *name, wcstring_list_t *args) { void event_fire_generic(const wchar_t *name, wcstring_list_t *args) {
CHECK(name, ); CHECK(name, );

View file

@ -125,12 +125,6 @@ void event_fire(const event_t *event);
/// May be called from signal handlers /// May be called from signal handlers
void event_fire_signal(int signal); void event_fire_signal(int signal);
/// Initialize the event-handling library.
void event_init();
/// Destroy the event-handling library.
void event_destroy();
/// Returns a string describing the specified event. /// Returns a string describing the specified event.
wcstring event_get_desc(const event_t &e); wcstring event_get_desc(const event_t &e);

View file

@ -376,11 +376,9 @@ int main(int argc, char **argv) {
const struct config_paths_t paths = determine_config_directory_paths(argv[0]); const struct config_paths_t paths = determine_config_directory_paths(argv[0]);
env_init(&paths); env_init(&paths);
proc_init(); proc_init();
event_init();
builtin_init(); builtin_init();
misc_init(); misc_init();
reader_init(); reader_init();
history_init();
parser_t &parser = parser_t::principal_parser(); parser_t &parser = parser_t::principal_parser();
@ -448,11 +446,8 @@ int main(int argc, char **argv) {
parser.emit_profiling(s_profiling_output_filename); parser.emit_profiling(s_profiling_output_filename);
} }
history_destroy(); history_save_all();
proc_destroy(); proc_destroy();
builtin_destroy();
reader_destroy();
event_destroy();
exit_without_destructors(exit_status); exit_without_destructors(exit_status);
return EXIT_FAILURE; // above line should always exit return EXIT_FAILURE; // above line should always exit
} }

View file

@ -299,7 +299,6 @@ static void setup_and_process_keys(bool continuous_mode) {
restore_term_mode(); restore_term_mode();
restore_term_foreground_process_group(); restore_term_foreground_process_group();
input_destroy(); input_destroy();
reader_destroy();
} }
static bool parse_debug_level_flag() { static bool parse_debug_level_flag() {

View file

@ -4412,7 +4412,6 @@ int main(int argc, char **argv) {
set_main_thread(); set_main_thread();
setup_fork_guards(); setup_fork_guards();
proc_init(); proc_init();
event_init();
builtin_init(); builtin_init();
env_init(); env_init();
misc_init(); misc_init();
@ -4478,9 +4477,6 @@ int main(int argc, char **argv) {
say(L"Encountered %d errors in low-level tests", err_count); say(L"Encountered %d errors in low-level tests", err_count);
if (s_test_run_count == 0) say(L"*** No Tests Were Actually Run! ***"); if (s_test_run_count == 0) say(L"*** No Tests Were Actually Run! ***");
reader_destroy();
builtin_destroy();
event_destroy();
proc_destroy(); proc_destroy();
if (err_count != 0) { if (err_count != 0) {

View file

@ -63,9 +63,6 @@ class function_info_t {
bool autoload); bool autoload);
}; };
/// Initialize function data.
void function_init();
/// Add a function. definition_line_offset is the line number of the function's definition within /// Add a function. definition_line_offset is the line number of the function's definition within
/// its source file. /// its source file.
void function_add(const function_data_t &data, const parser_t &parser, void function_add(const function_data_t &data, const parser_t &parser,

View file

@ -1836,8 +1836,6 @@ void history_t::incorporate_external_changes() {
} }
} }
void history_init() {}
void history_collection_t::save() { void history_collection_t::save() {
// Save all histories // Save all histories
auto &&h = histories.acquire(); auto &&h = histories.acquire();
@ -1846,11 +1844,7 @@ void history_collection_t::save() {
} }
} }
void history_destroy() { histories.save(); } void history_save_all() { histories.save(); }
void history_sanity_check() {
// No sanity checking implemented yet...
}
/// Return the prefix for the files to be used for command and read history. /// Return the prefix for the files to be used for command and read history.
wcstring history_session_id() { wcstring history_session_id() {

View file

@ -358,15 +358,8 @@ class history_search_t {
: history(), term(), search_type(HISTORY_SEARCH_TYPE_CONTAINS), case_sensitive(true) {} : history(), term(), search_type(HISTORY_SEARCH_TYPE_CONTAINS), case_sensitive(true) {}
}; };
/// Init history library. The history file won't actually be loaded until the first time a history
/// search is performed.
void history_init();
/// Saves the new history to disk. /// Saves the new history to disk.
void history_destroy(); void history_save_all();
/// Perform sanity checks.
void history_sanity_check();
/// Return the prefix for the files to be used for command and read history. /// Return the prefix for the files to be used for command and read history.
wcstring history_session_id(); wcstring history_session_id();

View file

@ -803,8 +803,6 @@ void reader_init() {
get_current_winsize(); get_current_winsize();
} }
void reader_destroy() { pthread_key_delete(generation_count_key); }
/// Restore the term mode if we own the terminal. It's important we do this before /// Restore the term mode if we own the terminal. It's important we do this before
/// restore_foreground_process_group, otherwise we won't think we own the terminal. /// restore_foreground_process_group, otherwise we won't think we own the terminal.
void restore_term_mode() { void restore_term_mode() {

View file

@ -58,9 +58,6 @@ void reader_sanity_check();
/// Initialize the reader. /// Initialize the reader.
void reader_init(); void reader_init();
/// Destroy and free resources used by the reader.
void reader_destroy();
/// Restore the term mode at startup. /// Restore the term mode at startup.
void restore_term_mode(); void restore_term_mode();

View file

@ -20,7 +20,6 @@ void sanity_lose() {
} }
bool sanity_check() { bool sanity_check() {
if (!insane && shell_is_interactive()) history_sanity_check();
if (!insane) reader_sanity_check(); if (!insane) reader_sanity_check();
if (!insane) kill_sanity_check(); if (!insane) kill_sanity_check();
if (!insane) proc_sanity_check(); if (!insane) proc_sanity_check();