diff options
-rw-r--r-- | src/conf.c | 10 | ||||
-rw-r--r-- | src/conf.h | 1 | ||||
-rw-r--r-- | src/main.c | 20 |
3 files changed, 7 insertions, 24 deletions
@@ -287,7 +287,6 @@ free_added_headers (vector_t add_headers) static void free_config (struct config_s *conf) { - safefree (conf->config_file); safefree (conf->logf_name); safefree (conf->stathost); safefree (conf->user); @@ -446,11 +445,6 @@ void initialize_config_defaults (struct config_s *conf) { memset (conf, 0, sizeof(*conf)); - conf->config_file = safestrdup (SYSCONFDIR "/tinyproxy.conf"); - if (!conf->config_file) { - fprintf (stderr, PACKAGE ": Could not allocate memory.\n"); - exit (EX_SOFTWARE); - } /* * Make sure the HTML error pages array is NULL to begin with. * (FIXME: Should have a better API for all this) @@ -470,10 +464,6 @@ static void initialize_with_defaults (struct config_s *conf, conf->logf_name = safestrdup (defaults->logf_name); } - if (defaults->config_file) { - conf->config_file = safestrdup (defaults->config_file); - } - conf->syslog = defaults->syslog; conf->port = defaults->port; @@ -39,7 +39,6 @@ typedef struct { struct config_s { vector_t basicauth_list; char *logf_name; - char *config_file; unsigned int syslog; /* boolean */ unsigned int port; char *stathost; @@ -49,6 +49,7 @@ */ struct config_s config; struct config_s config_defaults; +static const char* config_file; unsigned int received_sighup = FALSE; /* boolean */ /* @@ -248,7 +249,7 @@ int reload_config (void) shutdown_logging (); - ret = reload_config_file (config_defaults.config_file, &config, + ret = reload_config_file (config_file, &config, &config_defaults); if (ret != 0) { goto done; @@ -278,7 +279,7 @@ main (int argc, char **argv) exit (EX_SOFTWARE); } - initialize_config_defaults (&config_defaults); + config_file = SYSCONFDIR "/tinyproxy.conf"; while ((opt = getopt (argc, argv, "c:vdh")) != EOF) { switch (opt) { @@ -291,16 +292,7 @@ main (int argc, char **argv) break; case 'c': - if ((&config_defaults)->config_file != NULL) { - safefree ((&config_defaults)->config_file); - } - (&config_defaults)->config_file = safestrdup (optarg); - if (!(&config_defaults)->config_file) { - fprintf (stderr, - "%s: Could not allocate memory.\n", - argv[0]); - exit (EX_SOFTWARE); - } + config_file = optarg; break; case 'h': @@ -313,7 +305,9 @@ main (int argc, char **argv) } } - if (reload_config_file (config_defaults.config_file, + initialize_config_defaults (&config_defaults); + + if (reload_config_file (config_file, &config, &config_defaults)) { exit (EX_SOFTWARE); |