Browse Source

Remove various if's and such that are now unneeded

This is part 5 of the memory function / caller changes.
pull/1/head
Bram Matthys 3 years ago
parent
commit
f2e3712d62
No known key found for this signature in database
GPG Key ID: BF8116B163EAAE98
  1. 3
      src/api-isupport.c
  2. 12
      src/channel.c
  3. 3
      src/cloak.c
  4. 18
      src/conf.c
  5. 3
      src/dns.c
  6. 6
      src/extra.c
  7. 3
      src/match.c
  8. 2
      src/modules/antimixedutf8.c
  9. 2
      src/modules/antirandom.c
  10. 4
      src/modules/certfp.c
  11. 3
      src/modules/staff.c
  12. 7
      src/modules/svsnline.c
  13. 5
      src/modules/webredir.c
  14. 9
      src/url.c
  15. 3
      src/windows/rtf.c

3
src/api-isupport.c

@ -238,8 +238,7 @@ void ISupportDel(ISupport *isupport)
{
DelListItem(isupport, ISupports);
safe_free(isupport->token);
if (isupport->value)
safe_free(isupport->value);
safe_free(isupport->value);
safe_free(isupport);
make_isupportstrings();
}

12
src/channel.c

@ -1057,19 +1057,19 @@ int sub1_from_channel(Channel *chptr)
/* free extcmode params */
extcmode_free_paramlist(chptr->mode.extmodeparams);
if (chptr->mode_lock)
safe_free(chptr->mode_lock);
if (chptr->topic)
safe_free(chptr->topic);
if (chptr->topic_nick)
safe_free(chptr->topic_nick);
safe_free(chptr->mode_lock);
safe_free(chptr->topic);
safe_free(chptr->topic_nick);
if (chptr->prevch)
chptr->prevch->nextch = chptr->nextch;
else
channel = chptr->nextch;
if (chptr->nextch)
chptr->nextch->prevch = chptr->prevch;
(void)del_from_channel_hash_table(chptr->chname, chptr);
ircstats.channels--;
safe_free(chptr);
return 1;

3
src/cloak.c

@ -43,7 +43,6 @@ char *make_virthost(Client *sptr, char *curr, char *new, int mode)
strlcpy(new, mask, HOSTLEN + 1);
return NULL;
}
if (new)
safe_free(new);
safe_free(new);
return raw_strdup(mask);
}

18
src/conf.c

@ -550,8 +550,7 @@ void conf_channelmodes(char *modes, struct ChMode *store, int warn)
}
}
}
if (parambuf)
safe_free(parambuf);
safe_free(parambuf);
}
void chmode_str(struct ChMode *modes, char *mbuf, char *pbuf, size_t mbuf_size, size_t pbuf_size)
@ -790,8 +789,7 @@ void config_free(ConfigFile *cfptr)
nptr = cfptr->cf_next;
if (cfptr->cf_entries)
config_entry_free(cfptr->cf_entries);
if (cfptr->cf_filename)
safe_free(cfptr->cf_filename);
safe_free(cfptr->cf_filename);
safe_free(cfptr);
}
}
@ -1178,10 +1176,8 @@ static void config_entry_free(ConfigEntry *ceptr)
nptr = ceptr->ce_next;
if (ceptr->ce_entries)
config_entry_free(ceptr->ce_entries);
if (ceptr->ce_varname)
safe_free(ceptr->ce_varname);
if (ceptr->ce_vardata)
safe_free(ceptr->ce_vardata);
safe_free(ceptr->ce_varname);
safe_free(ceptr->ce_vardata);
safe_free(ceptr);
}
}
@ -10150,8 +10146,7 @@ void unload_notloaded_includes(void)
remove(inc->file);
}
safe_free(inc->url);
if (inc->errorbuf)
safe_free(inc->errorbuf);
safe_free(inc->errorbuf);
}
#endif
safe_free(inc->file);
@ -10184,8 +10179,7 @@ void unload_loaded_includes(void)
remove(inc->file);
}
safe_free(inc->url);
if (inc->errorbuf)
safe_free(inc->errorbuf);
safe_free(inc->errorbuf);
}
#endif
safe_free(inc->file);

3
src/dns.c

@ -616,8 +616,7 @@ static void unrealdns_freeandremovereq(DNSReq *r)
if (r->next)
r->next->prev = r->prev;
if (r->name)
safe_free(r->name);
safe_free(r->name);
safe_free(r);
}

6
src/extra.c

@ -126,10 +126,8 @@ void dcc_wipe_services(void)
if (dconf->flag.type2 == CONF_BAN_TYPE_AKILL)
{
DelListItem(dconf, conf_deny_dcc);
if (dconf->filename)
safe_free(dconf->filename);
if (dconf->reason)
safe_free(dconf->reason);
safe_free(dconf->filename);
safe_free(dconf->reason);
safe_free(dconf);
}
}

3
src/match.c

@ -857,8 +857,7 @@ int badword_config_process(ConfigItem_badword *ca, char *str)
void badword_config_free(ConfigItem_badword *e)
{
safe_free(e->word);
if (e->replace)
safe_free(e->replace);
safe_free(e->replace);
if (e->pcre2_expr)
pcre2_code_free(e->pcre2_expr);
safe_free(e);

2
src/modules/antimixedutf8.c

@ -333,8 +333,6 @@ int antimixedutf8_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
} else
if (!strcmp(cep->ce_varname, "ban-reason"))
{
if (cfg.ban_reason)
safe_free(cfg.ban_reason);
safe_strdup(cfg.ban_reason, cep->ce_vardata);
} else
if (!strcmp(cep->ce_varname, "ban-time"))

2
src/modules/antirandom.c

@ -698,8 +698,6 @@ int antirandom_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
} else
if (!strcmp(cep->ce_varname, "ban-reason"))
{
if (cfg.ban_reason)
safe_free(cfg.ban_reason);
safe_strdup(cfg.ban_reason, cep->ce_vardata);
} else
if (!strcmp(cep->ce_varname, "ban-time"))

4
src/modules/certfp.c

@ -141,9 +141,7 @@ int certfp_whois(Client *sptr, Client *acptr)
void certfp_free(ModData *m)
{
if (m->str)
safe_free(m->str);
m->str = NULL;
safe_free(m->str);
}
char *certfp_serialize(ModData *m)

3
src/modules/staff.c

@ -131,8 +131,7 @@ static void InitConf()
static void FreeConf()
{
if (staff_file)
safe_free(staff_file);
safe_free(staff_file);
}
/*** web routines */

7
src/modules/svsnline.c

@ -136,11 +136,8 @@ CMD_FUNC(cmd_svsnline)
if (bconf)
{
DelListItem(bconf, conf_ban);
if (bconf->mask)
safe_free(bconf->mask);
if (bconf->reason)
safe_free(bconf->reason);
safe_free(bconf->mask);
safe_free(bconf->reason);
safe_free(bconf);
}

5
src/modules/webredir.c

@ -87,8 +87,7 @@ static void init_config(void)
static void free_config(void)
{
if (cfg.url)
safe_free(cfg.url);
safe_free(cfg.url);
memset(&cfg, 0, sizeof(cfg)); /* needed! */
}
@ -185,8 +184,6 @@ int webredir_config_run(ConfigFile *cf, ConfigEntry *ce, int type)
{
if (!strcmp(cep->ce_varname, "url"))
{
if (cfg.url)
safe_free(cfg.url);
safe_strdup(cfg.url, cep->ce_vardata);
}
}

9
src/url.c

@ -179,8 +179,7 @@ char *download_file(const char *url, char **error)
if (!curl)
{
if (file)
safe_free(file);
safe_free(file);
strlcpy(errorbuf, "curl_easy_init() failed", sizeof(errorbuf));
*error = errorbuf;
return NULL;
@ -190,8 +189,7 @@ char *download_file(const char *url, char **error)
if (!fd)
{
snprintf(errorbuf, CURL_ERROR_SIZE, "Cannot write to %s: %s", tmp, strerror(errno));
if (file)
safe_free(file);
safe_free(file);
*error = errorbuf;
return NULL;
}
@ -223,8 +221,7 @@ char *download_file(const char *url, char **error)
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errorbuf);
res = curl_easy_perform(curl);
fclose(fd);
if (file)
safe_free(file);
safe_free(file);
if (res == CURLE_OK)
{
long last_mod;

3
src/windows/rtf.c

@ -84,8 +84,7 @@ DWORD CALLBACK BufferIt(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
memcpy(buf2+size,pbBuff,cb);
size += cb;
if (RTFBuf)
safe_free(RTFBuf);
safe_free(RTFBuf);
RTFBuf = buf2;

Loading…
Cancel
Save