Don't make config_file const in the config struct.

Michael
This commit is contained in:
Michael Adam 2009-12-07 00:30:41 +01:00
parent d0a91c2f9b
commit 1360f530f1
2 changed files with 9 additions and 2 deletions

View File

@ -215,6 +215,9 @@ process_cmdline (int argc, char **argv, struct config_s *conf)
break; break;
case 'c': case 'c':
if (conf->config_file != NULL) {
safefree (conf->config_file);
}
conf->config_file = safestrdup (optarg); conf->config_file = safestrdup (optarg);
if (!conf->config_file) { if (!conf->config_file) {
fprintf (stderr, fprintf (stderr,
@ -305,7 +308,11 @@ static void initialize_config_defaults (struct config_s *conf)
{ {
memset (conf, 0, sizeof(*conf)); memset (conf, 0, sizeof(*conf));
conf->config_file = SYSCONFDIR "/tinyproxy.conf"; conf->config_file = safestrdup (SYSCONFDIR "/tinyproxy.conf");
if (!conf->config_file) {
fprintf (stderr, PACKAGE ": Could not allocate memory.\n");
exit (EX_SOFTWARE);
}
conf->godaemon = TRUE; conf->godaemon = TRUE;
/* /*
* Make sure the HTML error pages array is NULL to begin with. * Make sure the HTML error pages array is NULL to begin with.

View File

@ -35,7 +35,7 @@
*/ */
struct config_s { struct config_s {
char *logf_name; char *logf_name;
const char *config_file; char *config_file;
unsigned int syslog; /* boolean */ unsigned int syslog; /* boolean */
int port; int port;
char *stathost; char *stathost;