Remove redundant malloc+memset calls in favor of calloc.

This commit is contained in:
Mid Favila 2022-12-07 11:55:31 -04:00
parent f93a73148f
commit 61415b6069
2 changed files with 8 additions and 10 deletions

View File

@ -12,11 +12,10 @@ int reqgen_gopher(const char *path, char **nbuf)
buflen = (strlen(REQ_GOPH) + strlen(path) + 1);
if( !(*nbuf = malloc(buflen)))
{
return(ERRMEM);
}
memset(*nbuf, 0, buflen);
if( !(*nbuf = calloc(buflen, sizeof(char))))
{
return(ERRMEM);
}
sprintf(*nbuf, REQ_GOPH, path);

View File

@ -12,11 +12,10 @@ int reqgen_http(const char *path, const char *fqdn, char **nbuf)
buflen = (strlen(REQ_HTTP) + strlen(path) + strlen(fqdn) + 1);
if( !(*nbuf = malloc(buflen)))
{
return(ERRMEM);
}
memset(*nbuf, 0, buflen);
if( !(*nbuf = calloc(buflen, sizeof(char))))
{
return(ERRMEM);
}
sprintf(*nbuf, REQ_HTTP, path, fqdn);