Skip to content
Snippets Groups Projects
Commit 52affeac authored by rswindell's avatar rswindell
Browse files

Moved free_cfg() here (from scfglib1.c).

Created free_text() to free TEXT.DAT memory.
load_cfg() will now free the previous configuration data and text.dat memory.
parent 39506fb1
No related branches found
No related tags found
No related merge requests found
......@@ -48,6 +48,8 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[])
FILE *instream;
read_cfg_text_t txt;
free_cfg(cfg); /* free allocated config parameters */
memset(&txt,0,sizeof(txt));
txt.openerr= "!ERROR: opening %s for read.";
txt.error= "!ERROR: offset %lu in %s:";
......@@ -74,6 +76,10 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[])
return(FALSE);
if(text!=NULL) {
/* Free existing text if allocated */
free_text(text);
strcpy(fname,"text.dat");
sprintf(str,"%s%s",cfg->ctrl_dir,fname);
if((instream=fnopen(NULL,str,O_RDONLY))==NULL) {
......@@ -109,6 +115,28 @@ BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[])
return(TRUE);
}
void free_cfg(scfg_t* cfg)
{
free_node_cfg(cfg);
free_main_cfg(cfg);
free_msgs_cfg(cfg);
free_file_cfg(cfg);
free_chat_cfg(cfg);
free_xtrn_cfg(cfg);
}
void free_text(char* text[])
{
int i;
if(text==NULL)
return;
for(i=0;i<TOTAL_TEXT;i++) {
FREE_AND_NULL(text[i]);
}
}
/****************************************************************************/
/* If the directory 'path' doesn't exist, create it. */
/****************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment