diff --git a/src/gopher.c b/src/gopher.c index 4c3cd46..c39b264 100644 --- a/src/gopher.c +++ b/src/gopher.c @@ -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); diff --git a/src/http.c b/src/http.c index aa20975..831a22a 100644 --- a/src/http.c +++ b/src/http.c @@ -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);