Remove redundant malloc+memset calls in favor of calloc.
This commit is contained in:
parent
f93a73148f
commit
61415b6069
|
@ -12,11 +12,10 @@ int reqgen_gopher(const char *path, char **nbuf)
|
||||||
|
|
||||||
buflen = (strlen(REQ_GOPH) + strlen(path) + 1);
|
buflen = (strlen(REQ_GOPH) + strlen(path) + 1);
|
||||||
|
|
||||||
if( !(*nbuf = malloc(buflen)))
|
if( !(*nbuf = calloc(buflen, sizeof(char))))
|
||||||
{
|
{
|
||||||
return(ERRMEM);
|
return(ERRMEM);
|
||||||
}
|
}
|
||||||
memset(*nbuf, 0, buflen);
|
|
||||||
|
|
||||||
sprintf(*nbuf, REQ_GOPH, path);
|
sprintf(*nbuf, REQ_GOPH, path);
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,10 @@ int reqgen_http(const char *path, const char *fqdn, char **nbuf)
|
||||||
|
|
||||||
buflen = (strlen(REQ_HTTP) + strlen(path) + strlen(fqdn) + 1);
|
buflen = (strlen(REQ_HTTP) + strlen(path) + strlen(fqdn) + 1);
|
||||||
|
|
||||||
if( !(*nbuf = malloc(buflen)))
|
if( !(*nbuf = calloc(buflen, sizeof(char))))
|
||||||
{
|
{
|
||||||
return(ERRMEM);
|
return(ERRMEM);
|
||||||
}
|
}
|
||||||
memset(*nbuf, 0, buflen);
|
|
||||||
|
|
||||||
sprintf(*nbuf, REQ_HTTP, path, fqdn);
|
sprintf(*nbuf, REQ_HTTP, path, fqdn);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue