allowfunc atoi
allowfunc atol
+allowfunc calloc
allowfunc fclose
allowfunc fdopen
allowfunc fopen
allowfunc fprintf
+allowfunc free
allowfunc gmtime
allowfunc localtime
+allowfunc malloc
allowfunc open
allowfunc printf
+allowfunc realloc
allowfunc snprintf
allowfunc socket
allowfunc sscanf
+allowfunc strdup
allowfunc strerror
allowfunc vsnprintf
`sizeof(int)` style.
- `SNPRINTF` - Found use of `snprintf()`. Since we use an internal replacement
- with a different return code etc, we prefer `msnprintf()`.
+ with a different return code etc, we prefer `curl_msnprintf()`.
- `SPACEAFTERPAREN`: there was a space after open parenthesis, `( text`.
aprintf
atoi
atol
+ calloc
fclose
fdopen
fopen
fprintf
+ free
freeaddrinfo
freopen
getaddrinfo
LoadLibraryExW
LoadLibraryW
localtime
+ malloc
mbstowcs
msnprintf
mvsnprintf
open
printf
+ realloc
recv
send
snprintf
sscanf
stat
strcat
+ strdup
strerror
strncat
strncpy
curl_ldap.h \
curl_md4.h \
curl_md5.h \
- curl_mem_undef.h \
- curl_memory.h \
curl_memrchr.h \
curl_ntlm_core.h \
curl_printf.h \
imap.h \
llist.h \
macos.h \
- memdebug.h \
mime.h \
mqtt.h \
multihandle.h \
#include "curlx/strparse.h"
#include "connect.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define MAX_ALTSVC_LINE 4095
#define MAX_ALTSVC_DATELEN 256
#define MAX_ALTSVC_HOSTLEN 2048
static void altsvc_free(struct altsvc *as)
{
- free(as->src.host);
- free(as->dst.host);
- free(as);
+ curlx_free(as->src.host);
+ curlx_free(as->dst.host);
+ curlx_free(as);
}
static struct altsvc *altsvc_createid(const char *srchost,
size_t srcport,
size_t dstport)
{
- struct altsvc *as = calloc(1, sizeof(struct altsvc));
+ struct altsvc *as = curlx_calloc(1, sizeof(struct altsvc));
if(!as)
return NULL;
DEBUGASSERT(hlen);
/* we need a private copy of the filename so that the altsvc cache file
name survives an easy handle reset */
- free(asi->filename);
- asi->filename = strdup(file);
+ curlx_free(asi->filename);
+ asi->filename = curlx_strdup(file);
if(!asi->filename)
return CURLE_OUT_OF_MEMORY;
*/
struct altsvcinfo *Curl_altsvc_init(void)
{
- struct altsvcinfo *asi = calloc(1, sizeof(struct altsvcinfo));
+ struct altsvcinfo *asi = curlx_calloc(1, sizeof(struct altsvcinfo));
if(!asi)
return NULL;
Curl_llist_init(&asi->list, NULL);
n = Curl_node_next(e);
altsvc_free(as);
}
- free(altsvc->filename);
- free(altsvc);
+ curlx_free(altsvc->filename);
+ curlx_free(altsvc);
*altsvcp = NULL; /* clear the pointer */
}
}
if(result && tempstore)
unlink(tempstore);
}
- free(tempstore);
+ curlx_free(tempstore);
return result;
}
# endif
#endif
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef HAVE_PROTO_BSDSOCKET_H
#ifdef __amigaos4__
LONG h_errnop = 0;
struct hostent *buf;
- buf = calloc(1, CURL_HOSTENT_SIZE);
+ buf = curlx_calloc(1, CURL_HOSTENT_SIZE);
if(buf) {
h = gethostbyname_r((STRPTR)hostname, buf,
(char *)buf + sizeof(struct hostent),
if(h) {
ai = Curl_he2ai(h, port);
}
- free(buf);
+ curlx_free(buf);
}
}
else {
#define HTTPSRR_WORKS
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define CARES_TIMEOUT_PER_ATTEMPT 2000
static int ares_ver = 0;
if((size_t)ai->ai_addrlen < ss_size)
continue;
- ca = malloc(sizeof(struct Curl_addrinfo) + ss_size);
+ ca = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size);
if(!ca) {
error = EAI_MEMORY;
break;
data->state.async.dns = NULL; /* clear */
data->state.async.port = port;
data->state.async.ip_version = ip_version;
- data->state.async.hostname = strdup(hostname);
+ data->state.async.hostname = curlx_strdup(hostname);
if(!data->state.async.hostname)
return CURLE_OUT_OF_MEMORY;
#ifdef USE_HTTPSRR
#include "select.h"
#include "curl_share.h"
#include "url.h"
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
/***********************************************************************
* Only for builds using asynchronous name resolves
#endif
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Curl_async_global_init()
if(destroy) {
Curl_mutex_destroy(&addr_ctx->mutx);
- free(addr_ctx->hostname);
+ curlx_free(addr_ctx->hostname);
if(addr_ctx->res)
Curl_freeaddrinfo(addr_ctx->res);
#ifndef CURL_DISABLE_SOCKETPAIR
#endif
wakeup_close(addr_ctx->sock_pair[0]);
#endif
- free(addr_ctx);
+ curlx_free(addr_ctx);
}
*paddr_ctx = NULL;
}
const char *hostname, int port,
const struct addrinfo *hints)
{
- struct async_thrdd_addr_ctx *addr_ctx = calloc(1, sizeof(*addr_ctx));
+ struct async_thrdd_addr_ctx *addr_ctx = curlx_calloc(1, sizeof(*addr_ctx));
if(!addr_ctx)
return NULL;
/* Copying hostname string because original can be destroyed by parent
* thread during gethostbyname execution.
*/
- addr_ctx->hostname = strdup(hostname);
+ addr_ctx->hostname = curlx_strdup(hostname);
if(!addr_ctx->hostname)
goto err_exit;
status = ares_init_options(&thrdd->rr.channel, NULL, 0);
if(status != ARES_SUCCESS) {
thrdd->rr.channel = NULL;
- free(rrname);
+ curlx_free(rrname);
return CURLE_FAILED_INIT;
}
#ifdef CURLDEBUG
const char *servers = getenv("CURL_DNS_SERVER");
status = ares_set_servers_ports_csv(thrdd->rr.channel, servers);
if(status) {
- free(rrname);
+ curlx_free(rrname);
return CURLE_FAILED_INIT;
}
}
data->state.async.done = FALSE;
data->state.async.port = port;
data->state.async.ip_version = ip_version;
- free(data->state.async.hostname);
- data->state.async.hostname = strdup(hostname);
+ curlx_free(data->state.async.hostname);
+ data->state.async.hostname = curlx_strdup(hostname);
if(!data->state.async.hostname)
goto err_exit;
#include "curl_setup.h"
#include "bufq.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static bool chunk_is_empty(const struct buf_chunk *chunk)
{
return chunk->r_offset >= chunk->w_offset;
while(*anchor) {
chunk = *anchor;
*anchor = chunk->next;
- free(chunk);
+ curlx_free(chunk);
}
}
return CURLE_OUT_OF_MEMORY;
}
- chunk = calloc(1, sizeof(*chunk) + pool->chunk_size);
+ chunk = curlx_calloc(1, sizeof(*chunk) + pool->chunk_size);
if(!chunk) {
*pchunk = NULL;
return CURLE_OUT_OF_MEMORY;
struct buf_chunk *chunk)
{
if(pool->spare_count >= pool->spare_max) {
- free(chunk);
+ curlx_free(chunk);
}
else {
chunk_reset(chunk);
return NULL;
}
- chunk = calloc(1, sizeof(*chunk) + q->chunk_size);
+ chunk = curlx_calloc(1, sizeof(*chunk) + q->chunk_size);
if(!chunk)
return NULL;
chunk->dlen = q->chunk_size;
/* SOFT_LIMIT allowed us more than max. free spares until
* we are at max again. Or free them if we are configured
* to not use spares. */
- free(chunk);
+ curlx_free(chunk);
--q->chunk_count;
}
else {
#include "bufref.h"
#include "strdup.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef DEBUGBUILD
#define SIGNATURE 0x5c48e9b2 /* Random pattern. */
#endif
#include "multiif.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
typedef enum {
H1_TUNNEL_INIT, /* init/default/no tunnel state */
return CURLE_UNSUPPORTED_PROTOCOL;
}
- ts = calloc(1, sizeof(*ts));
+ ts = curlx_calloc(1, sizeof(*ts));
if(!ts)
return CURLE_OUT_OF_MEMORY;
curlx_dyn_free(&ts->rcvbuf);
curlx_dyn_free(&ts->request_data);
Curl_httpchunk_free(data, &ts->ch);
- free(ts);
+ curlx_free(ts);
cf->ctx = NULL;
}
}
/* This only happens if we have looped here due to authentication
reasons, and we do not really use the newly cloned URL here
- then. Just free() it. */
+ then. Just free it. */
Curl_safefree(data->req.newurl);
result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1);
CURL_TRC_CF(data, cf, "CONNECT: fwd auth header '%s'", header);
result = Curl_http_input_auth(data, proxy, auth);
- free(auth);
+ curlx_free(auth);
if(result)
return result;
#include "curlx/warnless.h"
#include "cf-h2-proxy.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define PROXY_H2_CHUNK_SIZE (16*1024)
#define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024)
{
if(ctx) {
cf_h2_proxy_ctx_clear(ctx);
- free(ctx);
+ curlx_free(ctx);
}
}
result = CURLE_OK;
out:
- free(nva);
+ curlx_free(nva);
Curl_dynhds_free(&h2_headers);
*pstream_id = stream_id;
return result;
CURLcode result = CURLE_OUT_OF_MEMORY;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx)
goto out;
#include "multiif.h"
#include "select.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
typedef enum {
HAPROXY_INIT, /* init/default/no tunnel state */
{
if(ctx) {
curlx_dyn_free(&ctx->data_out);
- free(ctx);
+ curlx_free(ctx);
}
}
CURLcode result;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "select.h"
#include "vquic/vquic.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
typedef enum {
CF_HC_INIT,
CF_HC_CONNECT,
CURLcode result = CURLE_OK;
size_t i;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
out:
*pcf = result ? NULL : cf;
- free(ctx);
+ curlx_free(ctx);
return result;
}
#include "select.h"
#include "vquic/vquic.h" /* for quic cfilters */
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
struct transport_provider {
uint8_t transport;
if(a) {
if(a->cf)
Curl_conn_cf_discard_chain(&a->cf, data);
- free(a);
+ curlx_free(a);
}
}
CURLcode result = CURLE_OK;
*pa = NULL;
- a = calloc(1, sizeof(*a));
+ a = curlx_calloc(1, sizeof(*a));
if(!a)
return CURLE_OUT_OF_MEMORY;
(void)data;
(void)conn;
*pcf = NULL;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
out:
if(result) {
Curl_safefree(*pcf);
- free(ctx);
+ curlx_free(ctx);
}
return result;
}
#include "curlx/strerr.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(USE_IPV6) && defined(IPV6_V6ONLY) && defined(_WIN32)
/* It makes support for IPv4-mapped IPv6 addresses.
++host_part;
*host = Curl_memdup0(host_part, len - (host_part - input));
if(!*host) {
- free(*iface);
+ curlx_free(*iface);
*iface = NULL;
return CURLE_OUT_OF_MEMORY;
}
cf_socket_close(cf, data);
CURL_TRC_CF(data, cf, "destroy");
- free(ctx);
+ curlx_free(ctx);
cf->ctx = NULL;
}
goto out;
}
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
(void)data;
(void)conn;
DEBUGASSERT(transport == TRNSPRT_UDP || transport == TRNSPRT_QUIC);
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
(void)data;
(void)conn;
DEBUGASSERT(transport == TRNSPRT_UNIX);
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
Curl_conn_cf_discard_all(data, conn, sockindex);
DEBUGASSERT(conn->sock[sockindex] == CURL_SOCKET_BAD);
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "curlx/warnless.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void cf_cntrl_update_info(struct Curl_easy *data,
struct connectdata *conn);
*/
cf->next = NULL;
cf->cft->destroy(cf, data);
- free(cf);
+ curlx_free(cf);
cf = cfn;
}
}
CURLcode result = CURLE_OUT_OF_MEMORY;
DEBUGASSERT(cft);
- cf = calloc(1, sizeof(*cf));
+ cf = curlx_calloc(1, sizeof(*cf));
if(!cf)
goto out;
#include "curlx/strparse.h"
#include "uint-table.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define CPOOL_IS_LOCKED(c) ((c) && (c)->locked)
struct cpool_bundle *bundle;
size_t dest_len = strlen(dest) + 1;
- bundle = calloc(1, sizeof(*bundle) + dest_len - 1);
+ bundle = curlx_calloc(1, sizeof(*bundle) + dest_len - 1);
if(!bundle)
return NULL;
Curl_llist_init(&bundle->conns, NULL);
static void cpool_bundle_destroy(struct cpool_bundle *bundle)
{
DEBUGASSERT(!Curl_llist_count(&bundle->conns));
- free(bundle);
+ curlx_free(bundle);
}
/* Add a connection to a bundle */
#include "http_proxy.h"
#include "socks.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if !defined(CURL_DISABLE_ALTSVC) || defined(USE_HTTPSRR)
enum alpnid Curl_alpn2alpnid(const unsigned char *name, size_t len)
CURLcode result = CURLE_OK;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
out:
*pcf = result ? NULL : cf;
if(ctx) {
- free(ctx);
+ curlx_free(ctx);
}
return result;
}
#include "http.h"
#include "content_encoding.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define CONTENT_ENCODING_DEFAULT "identity"
#ifndef CURL_DISABLE_HTTP
zalloc_cb(voidpf opaque, unsigned int items, unsigned int size)
{
(void)opaque;
- /* not a typo, keep it calloc() */
- return (voidpf) calloc(items, size);
+ /* not a typo, keep it curlx_calloc() */
+ return (voidpf)curlx_calloc(items, size);
}
static void
zfree_cb(voidpf opaque, voidpf ptr)
{
(void)opaque;
- free(ptr);
+ curlx_free(ptr);
}
static CURLcode
#include "llist.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void strstore(char **str, const char *newstr, size_t len);
/* number of seconds in 400 days */
static void freecookie(struct Cookie *co)
{
- free(co->domain);
- free(co->path);
- free(co->spath);
- free(co->name);
- free(co->value);
- free(co);
+ curlx_free(co->domain);
+ curlx_free(co->path);
+ curlx_free(co->spath);
+ curlx_free(co->name);
+ curlx_free(co->value);
+ curlx_free(co);
}
static bool cookie_tailmatch(const char *cookie_domain,
/* RFC6265 5.2.4 The Path Attribute */
if(cookie_path[0] != '/')
/* Let cookie-path be the default-path. */
- return strdup("/");
+ return curlx_strdup("/");
/* remove trailing slash when path is non-empty */
/* convert /hoge/ to /hoge */
static void strstore(char **str, const char *newstr, size_t len)
{
DEBUGASSERT(str);
- free(*str);
+ curlx_free(*str);
if(!len) {
len++;
newstr = "";
strstore(&co->path, curlx_str(&val), curlx_strlen(&val));
if(!co->path)
return CURLE_OUT_OF_MEMORY;
- free(co->spath); /* if this is set again */
+ curlx_free(co->spath); /* if this is set again */
co->spath = sanitize_cookie_path(co->path);
if(!co->spath)
return CURLE_OUT_OF_MEMORY;
if(!co->domain && domain) {
/* no domain was given in the header line, set the default */
- co->domain = strdup(domain);
+ co->domain = curlx_strdup(domain);
if(!co->domain)
return CURLE_OUT_OF_MEMORY;
}
break;
}
/* this does not look like a path, make one up! */
- co->path = strdup("/");
+ co->path = curlx_strdup("/");
if(!co->path)
return CURLE_OUT_OF_MEMORY;
- co->spath = strdup("/");
+ co->spath = curlx_strdup("/");
if(!co->spath)
return CURLE_OUT_OF_MEMORY;
fields++; /* add a field and fall down to secure */
}
if(fields == 6) {
/* we got a cookie with blank contents, fix it */
- co->value = strdup("");
+ co->value = curlx_strdup("");
if(!co->value)
return CURLE_OUT_OF_MEMORY;
else
return CURLE_OK; /* silently ignore */
/* First, alloc and init a new struct for it */
- co = calloc(1, sizeof(struct Cookie));
+ co = curlx_calloc(1, sizeof(struct Cookie));
if(!co)
return CURLE_OUT_OF_MEMORY; /* bail out if we are this low on memory */
struct CookieInfo *Curl_cookie_init(void)
{
int i;
- struct CookieInfo *ci = calloc(1, sizeof(struct CookieInfo));
+ struct CookieInfo *ci = curlx_calloc(1, sizeof(struct CookieInfo));
if(!ci)
return NULL;
size_t i;
/* alloc an array and store all cookie pointers */
- array = malloc(sizeof(struct Cookie *) * matches);
+ array = curlx_malloc(sizeof(struct Cookie *) * matches);
if(!array) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
for(i = 0; i < matches; i++)
Curl_llist_append(list, array[i], &array[i]->getnode);
- free(array); /* remove the temporary data again */
+ curlx_free(array); /* remove the temporary data again */
}
*okay = TRUE;
{
if(ci) {
Curl_cookie_clearall(ci);
- free(ci); /* free the base struct as well */
+ curlx_free(ci); /* free the base struct as well */
}
}
struct Cookie **array;
struct Curl_llist_node *n;
- array = calloc(1, sizeof(struct Cookie *) * ci->numcookies);
+ array = curlx_calloc(1, sizeof(struct Cookie *) * ci->numcookies);
if(!array) {
error = CURLE_OUT_OF_MEMORY;
goto error;
for(i = 0; i < nvalid; i++) {
char *format_ptr = get_netscape_format(array[i]);
if(!format_ptr) {
- free(array);
+ curlx_free(array);
error = CURLE_OUT_OF_MEMORY;
goto error;
}
curl_mfprintf(out, "%s\n", format_ptr);
- free(format_ptr);
+ curlx_free(format_ptr);
}
- free(array);
+ curlx_free(array);
}
if(!use_stdout) {
* no need to inspect the error, any error case should have jumped into the
* error block below.
*/
- free(tempstore);
+ curlx_free(tempstore);
return CURLE_OK;
error:
curlx_fclose(out);
if(tempstore) {
unlink(tempstore);
- free(tempstore);
+ curlx_free(tempstore);
}
return error;
}
}
beg = Curl_slist_append_nodup(list, line);
if(!beg) {
- free(line);
+ curlx_free(line);
curl_slist_free_all(list);
return NULL;
}
#include "select.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void cshutdn_run_conn_handler(struct Curl_easy *data,
struct connectdata *conn)
#include "curlx/inet_pton.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Curl_freeaddrinfo()
*
for(ca = cahead; ca; ca = canext) {
canext = ca->ai_next;
- free(ca);
+ curlx_free(ca);
}
}
if((size_t)ai->ai_addrlen < ss_size)
continue;
- ca = malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
+ ca = curlx_malloc(sizeof(struct Curl_addrinfo) + ss_size + namelen);
if(!ca) {
error = EAI_MEMORY;
break;
ss_size = sizeof(struct sockaddr_in);
/* allocate memory to hold the struct, the address and the name */
- ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
+ ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + namelen);
if(!ai) {
result = CURLE_OUT_OF_MEMORY;
break;
return CURLE_BAD_FUNCTION_ARGUMENT;
/* allocate memory to hold the struct, the address and the name */
- ai = calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen);
+ ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + addrsize + namelen);
if(!ai)
return CURLE_OUT_OF_MEMORY;
/* put the address after the struct */
*longpath = FALSE;
- ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
+ ai = curlx_calloc(1,
+ sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_un));
if(!ai)
return NULL;
ai->ai_addr = (void *)((char *)ai + sizeof(struct Curl_addrinfo));
/* sun_path must be able to store the null-terminated path */
path_len = strlen(path) + 1;
if(path_len > sizeof(sa_un->sun_path)) {
- free(ai);
+ curlx_free(ai);
*longpath = TRUE;
return NULL;
}
#include <curl/curl.h>
#include "curl_fnmatch.h"
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
#ifndef HAVE_FNMATCH
#include "rand.h"
#include "curl_fopen.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
The dirslash() function breaks a null-terminated pathname string into
directory and filename components then returns the directory component up
/* The temp filename should not end up too long for the target file
system */
tempstore = curl_maprintf("%s%s.tmp", dir, randbuf);
- free(dir);
+ curlx_free(dir);
}
if(!tempstore) {
unlink(tempstore);
}
- free(tempstore);
+ curlx_free(tempstore);
return result;
}
!defined(CURL_DISABLE_HSTS) || !defined(CURL_DISABLE_NETRC)
#include "curl_get_line.h"
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
#define appendnl(b) \
curlx_dyn_addn(buf, "\n", 1)
#ifdef DEBUGBUILD
#if defined(HAVE_GSSGNU) || !defined(_WIN32)
-/* To avoid memdebug macro replacement, wrap the name in parentheses to call
- the original version. It is freed via the GSS API gss_release_buffer(). */
-#define Curl_gss_alloc (malloc)
-#define Curl_gss_free (free)
+#define Curl_gss_alloc malloc /* freed via the GSS API gss_release_buffer() */
+#define Curl_gss_free free /* pair of the above */
#define CURL_GSS_STUB
/* For correctness this would be required for all platforms, not only Windows,
but, as of v1.22.1, MIT Kerberos uses a special allocator only for Windows,
#endif
#endif /* DEBUGBUILD */
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef __GNUC__
#define CURL_ALIGN8 __attribute__((aligned(8)))
#else
return GSS_S_FAILURE;
}
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
*min = STUB_GSS_NO_MEMORY;
return GSS_S_FAILURE;
else if(ctx->have_ntlm)
ctx->sent = STUB_GSS_NTLM1;
else {
- free(ctx);
+ curlx_free(ctx);
*min = STUB_GSS_NO_MECH;
return GSS_S_FAILURE;
}
token = Curl_gss_alloc(length);
if(!token) {
- free(ctx);
+ curlx_free(ctx);
*min = STUB_GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
&target_desc, &name_type);
if(GSS_ERROR(major_status)) {
Curl_gss_free(token);
- free(ctx);
+ curlx_free(ctx);
*min = STUB_GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
if(strlen(creds) + target_desc.length + 5 >= sizeof(ctx->creds)) {
Curl_gss_free(token);
- free(ctx);
+ curlx_free(ctx);
*min = STUB_GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
if(used >= length) {
Curl_gss_free(token);
- free(ctx);
+ curlx_free(ctx);
*min = STUB_GSS_NO_MEMORY;
return GSS_S_FAILURE;
}
return GSS_S_FAILURE;
}
- free(*context);
+ curlx_free(*context);
*context = NULL;
*min = 0;
+++ /dev/null
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-/* Unset redefined system symbols. */
-
-#undef strdup
-#undef malloc
-#undef calloc
-#undef realloc
-#undef free
-#ifdef _WIN32
-#undef Curl_tcsdup
-#endif
-
-#undef HEADER_CURL_MEMORY_H
-#undef HEADER_CURL_MEMDEBUG_H
+++ /dev/null
-#ifndef HEADER_CURL_MEMORY_H
-#define HEADER_CURL_MEMORY_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-/*
- * Nasty internal details ahead...
- *
- * File curl_memory.h must be included by _all_ *.c source files
- * that use memory related functions strdup, malloc, calloc, realloc
- * or free, and given source file is used to build libcurl library.
- * It should be included immediately before memdebug.h as the last files
- * included to avoid undesired interaction with other memory function
- * headers in dependent libraries.
- *
- * There is nearly no exception to above rule. All libcurl source
- * files in 'lib' subdirectory as well as those living deep inside
- * 'packages' subdirectories and linked together in order to build
- * libcurl library shall follow it.
- *
- * File lib/strdup.c is an exception, given that it provides a strdup
- * clone implementation while using malloc. Extra care needed inside
- * this one.
- *
- * The need for curl_memory.h inclusion is due to libcurl's feature
- * of allowing library user to provide memory replacement functions,
- * memory callbacks, at runtime with curl_global_init_mem()
- *
- * Any *.c source file used to build libcurl library that does not
- * include curl_memory.h and uses any memory function of the five
- * mentioned above will compile without any indication, but it will
- * trigger weird memory related issues at runtime.
- *
- */
-
-#ifndef CURLDEBUG
-
-/*
- * libcurl's 'memory tracking' system defines strdup, malloc, calloc,
- * realloc and free, along with others, in memdebug.h in a different
- * way although still using memory callbacks forward declared above.
- * When using the 'memory tracking' system (CURLDEBUG defined) we do
- * not define here the five memory functions given that definitions
- * from memdebug.h are the ones that shall be used.
- */
-
-#undef strdup
-#define strdup(ptr) Curl_cstrdup(ptr)
-#undef malloc
-#define malloc(size) Curl_cmalloc(size)
-#undef calloc
-#define calloc(nbelem,size) Curl_ccalloc(nbelem, size)
-#undef realloc
-#define realloc(ptr,size) Curl_crealloc(ptr, size)
-#undef free
-#define free(ptr) Curl_cfree(ptr)
-
-#ifdef _WIN32
-#undef Curl_tcsdup
-#ifdef UNICODE
-#define Curl_tcsdup(ptr) Curl_wcsdup(ptr)
-#else
-#define Curl_tcsdup(ptr) Curl_cstrdup(ptr)
-#endif
-#endif /* _WIN32 */
-
-#endif /* CURLDEBUG */
-#endif /* HEADER_CURL_MEMORY_H */
#include <curl/curl.h>
#include "curl_memrchr.h"
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
#ifndef HAVE_MEMRCHR
/*
#include "curl_endian.h"
#include "curl_md4.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef USE_CURL_DES_SET_ODD_PARITY
/*
* curl_des_set_odd_parity()
CURLcode result;
if(len > SIZE_MAX/2) /* avoid integer overflow */
return CURLE_OUT_OF_MEMORY;
- pw = len ? malloc(len * 2) : (unsigned char *)strdup("");
+ pw = len ? curlx_malloc(len * 2) : (unsigned char *)curlx_strdup("");
if(!pw)
return CURLE_OUT_OF_MEMORY;
if(!result)
memset(ntbuffer + 16, 0, 21 - 16);
- free(pw);
+ curlx_free(pw);
return result;
}
return CURLE_OUT_OF_MEMORY;
identity_len = (userlen + domlen) * 2;
- identity = malloc(identity_len + 1);
+ identity = curlx_malloc(identity_len + 1);
if(!identity)
return CURLE_OUT_OF_MEMORY;
result = Curl_hmacit(&Curl_HMAC_MD5, ntlmhash, 16, identity, identity_len,
ntlmv2hash);
- free(identity);
+ curlx_free(identity);
return result;
}
len = HMAC_MD5_LENGTH + NTLMv2_BLOB_LEN;
/* Allocate the response */
- ptr = calloc(1, len);
+ ptr = curlx_calloc(1, len);
if(!ptr)
return CURLE_OUT_OF_MEMORY;
result = Curl_hmacit(&Curl_HMAC_MD5, ntlmv2hash, HMAC_MD5_LENGTH, ptr + 8,
NTLMv2_BLOB_LEN + 8, hmac_output);
if(result) {
- free(ptr);
+ curlx_free(ptr);
return result;
}
#include <curl/curl.h>
#include <librtmp/rtmp.h>
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(_WIN32) && !defined(USE_LWIPSOCK)
#define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
#define SET_RCVTIMEO(tv,s) int tv = s*1000
#include "curlx/warnless.h"
#include "sendf.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Supported mechanisms */
static const struct {
const char *name; /* Name */
* This macro also assigns NULL to given pointer when free'd.
*/
#define Curl_safefree(ptr) \
- do { free(ptr); (ptr) = NULL;} while(0)
+ do { curlx_free(ptr); (ptr) = NULL;} while(0)
#include <curl/curl.h> /* for CURL_EXTERN, mprintf.h */
#endif /* CURLDEBUG */
+/* Allocator macros */
+
+#ifdef CURLDEBUG
+
+#define curlx_strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
+#define curlx_malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
+#define curlx_calloc(nbelem,size) \
+ curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
+#define curlx_realloc(ptr,size) \
+ curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
+#define curlx_free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
+
+#ifdef _WIN32
+#ifdef UNICODE
+#define curlx_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
+#else
+#define curlx_tcsdup(ptr) curlx_strdup(ptr)
+#endif
+#endif /* _WIN32 */
+
+#else /* !CURLDEBUG */
+
+#ifdef BUILDING_LIBCURL
+#define curlx_strdup(ptr) Curl_cstrdup(ptr)
+#define curlx_malloc(size) Curl_cmalloc(size)
+#define curlx_calloc(nbelem,size) Curl_ccalloc(nbelem, size)
+#define curlx_realloc(ptr,size) Curl_crealloc(ptr, size)
+#define curlx_free(ptr) Curl_cfree(ptr)
+#else /* !BUILDING_LIBCURL */
+#ifdef _WIN32
+#define curlx_strdup(ptr) _strdup(ptr)
+#else
+#define curlx_strdup(ptr) strdup(ptr)
+#endif
+#define curlx_malloc(size) malloc(size)
+#define curlx_calloc(nbelem,size) calloc(nbelem, size)
+#define curlx_realloc(ptr,size) realloc(ptr, size)
+#define curlx_free(ptr) free(ptr)
+#endif /* BUILDING_LIBCURL */
+
+#ifdef _WIN32
+#ifdef UNICODE
+#define curlx_tcsdup(ptr) Curl_wcsdup(ptr)
+#else
+#define curlx_tcsdup(ptr) curlx_strdup(ptr)
+#endif
+#endif /* _WIN32 */
+
+#endif /* CURLDEBUG */
+
/* Some versions of the Android NDK is missing the declaration */
#if defined(HAVE_GETPWUID_R) && \
defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
#endif
#endif /* HEADER_CURL_SETUP_H */
-
-#include "curl_mem_undef.h"
#include "hsts.h"
#include "url.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
CURLSH *
curl_share_init(void)
{
- struct Curl_share *share = calloc(1, sizeof(struct Curl_share));
+ struct Curl_share *share = curlx_calloc(1, sizeof(struct Curl_share));
if(share) {
share->magic = CURL_GOOD_SHARE;
share->specifier |= (1 << CURL_LOCK_DATA_SHARE);
Curl_dnscache_init(&share->dnscache, 23);
share->admin = curl_easy_init();
if(!share->admin) {
- free(share);
+ curlx_free(share);
return NULL;
}
/* admin handles have mid 0 */
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
share->magic = 0;
- free(share);
+ curlx_free(share);
return CURLSHE_OK;
}
#include "system_win32.h"
#include "curlx/warnless.h"
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Pointer to SSPI dispatch table */
PSecurityFunctionTable Curl_pSecFn = NULL;
}
/* Setup the identity's user and length */
- dup_user.tchar_ptr = Curl_tcsdup(user.tchar_ptr);
+ dup_user.tchar_ptr = curlx_tcsdup(user.tchar_ptr);
if(!dup_user.tchar_ptr) {
curlx_unicodefree(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
dup_user.tchar_ptr = NULL;
/* Setup the identity's domain and length */
- dup_domain.tchar_ptr = malloc(sizeof(TCHAR) * (domlen + 1));
+ dup_domain.tchar_ptr = curlx_malloc(sizeof(TCHAR) * (domlen + 1));
if(!dup_domain.tchar_ptr) {
curlx_unicodefree(useranddomain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
passwd.tchar_ptr = curlx_convert_UTF8_to_tchar(passwdp);
if(!passwd.tchar_ptr)
return CURLE_OUT_OF_MEMORY;
- dup_passwd.tchar_ptr = Curl_tcsdup(passwd.tchar_ptr);
+ dup_passwd.tchar_ptr = curlx_tcsdup(passwd.tchar_ptr);
if(!dup_passwd.tchar_ptr) {
curlx_unicodefree(passwd.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
#endif
#include "curl_threads.h"
-#include "curl_memory.h"
-/* The last #include FILE should be: */
-#include "memdebug.h"
#ifdef USE_THREADS_POSIX
unsigned int (*func)(void *) = ac->func;
void *real_arg = ac->arg;
- free(ac);
+ curlx_free(ac);
(*func)(real_arg);
curl_thread_t Curl_thread_create(CURL_THREAD_RETURN_T
(CURL_STDCALL *func) (void *), void *arg)
{
- curl_thread_t t = malloc(sizeof(pthread_t));
- struct Curl_actual_call *ac = malloc(sizeof(struct Curl_actual_call));
+ curl_thread_t t = curlx_malloc(sizeof(pthread_t));
+ struct Curl_actual_call *ac = curlx_malloc(sizeof(struct Curl_actual_call));
int rc;
if(!(ac && t))
goto err;
return t;
err:
- free(t);
- free(ac);
+ curlx_free(t);
+ curlx_free(ac);
return curl_thread_t_null;
}
{
if(*hnd != curl_thread_t_null) {
pthread_detach(**hnd);
- free(*hnd);
+ curlx_free(*hnd);
*hnd = curl_thread_t_null;
}
}
{
int ret = (pthread_join(**hnd, NULL) == 0);
- free(*hnd);
+ curlx_free(*hnd);
*hnd = curl_thread_t_null;
return ret;
#include "vtls/vtls.h"
#include "vquic/vquic.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void trc_write(struct Curl_easy *data, curl_infotype type,
const char *ptr, size_t size)
{
#include "warnless.h"
#include "base64.h"
-/* The last 2 #include files should be in this order */
-#ifdef BUILDING_LIBCURL
-#include "../curl_memory.h"
-#endif
-#include "../memdebug.h"
-
/* ---- Base64 Encoding/Decoding Table --- */
const char Curl_base64encdec[]=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
rawlen = (numQuantums * 3) - padding;
/* Allocate our buffer including room for a null-terminator */
- newstr = malloc(rawlen + 1);
+ newstr = curlx_malloc(rawlen + 1);
if(!newstr)
return CURLE_OUT_OF_MEMORY;
return CURLE_OK;
bad:
- free(newstr);
+ curlx_free(newstr);
return CURLE_BAD_CONTENT_ENCODING;
}
if(insize > CURL_MAX_BASE64_INPUT)
return CURLE_TOO_LARGE;
- base64data = output = malloc((insize + 2) / 3 * 4 + 1);
+ base64data = output = curlx_malloc((insize + 2) / 3 * 4 + 1);
if(!output)
return CURLE_OUT_OF_MEMORY;
#include "../curl_setup.h"
#include "dynbuf.h"
#include "../curl_printf.h"
-#ifdef BUILDING_LIBCURL
-#include "../curl_memory.h"
-#endif
-#include "../memdebug.h"
#define MIN_FIRST_ALLOC 32
if(a != s->allc) {
/* this logic is not using Curl_saferealloc() to make the tool not have to
include that as well when it uses this code */
- void *p = realloc(s->bufr, a);
+ void *p = curlx_realloc(s->bufr, a);
if(!p) {
curlx_dyn_free(s);
return CURLE_OUT_OF_MEMORY;
if(str) {
CURLcode result = dyn_nappend(s, (const unsigned char *)str, strlen(str));
- free(str);
+ curlx_free(str);
return result;
}
/* If we failed, we cleanup the whole buffer and return error */
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) Danieal Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
***************************************************************************/
/*
- * This file is 'mem-include-scan' clean, which means its memory allocations
- * are not tracked by the curl memory tracker memdebug, so they must not use
- * `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid
- * these macro replacements, wrap the names in parentheses to call the original
- * versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc.
+ * Use system allocators to avoid infinite recursion when called by curl's
+ * memory tracker memdebug functions.
*/
#include "../curl_setup.h"
goto cleanup;
if(!needed || needed >= max_path_len)
goto cleanup;
- ibuf = (malloc)(needed * sizeof(wchar_t));
+ /* !checksrc! disable BANNEDFUNC 1 */
+ ibuf = malloc(needed * sizeof(wchar_t));
if(!ibuf)
goto cleanup;
if(mbstowcs_s(&count, ibuf, needed, in, needed - 1))
/* skip paths that are not excessive and do not need modification */
if(needed <= MAX_PATH)
goto cleanup;
- fbuf = (malloc)(needed * sizeof(wchar_t));
+ /* !checksrc! disable BANNEDFUNC 1 */
+ fbuf = malloc(needed * sizeof(wchar_t));
if(!fbuf)
goto cleanup;
count = (size_t)GetFullPathNameW(in_w, (DWORD)needed, fbuf, NULL);
if(needed > max_path_len)
goto cleanup;
- temp = (malloc)(needed * sizeof(wchar_t));
+ /* !checksrc! disable BANNEDFUNC 1 */
+ temp = malloc(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
if(wcsncpy_s(temp, needed, L"\\\\?\\UNC\\", 8)) {
- (free)(temp);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(temp);
goto cleanup;
}
if(wcscpy_s(temp + 8, needed, fbuf + 2)) {
- (free)(temp);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(temp);
goto cleanup;
}
}
if(needed > max_path_len)
goto cleanup;
- temp = (malloc)(needed * sizeof(wchar_t));
+ /* !checksrc! disable BANNEDFUNC 1 */
+ temp = malloc(needed * sizeof(wchar_t));
if(!temp)
goto cleanup;
if(wcsncpy_s(temp, needed, L"\\\\?\\", 4)) {
- (free)(temp);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(temp);
goto cleanup;
}
if(wcscpy_s(temp + 4, needed, fbuf)) {
- (free)(temp);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(temp);
goto cleanup;
}
}
- (free)(fbuf);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fbuf);
fbuf = temp;
}
goto cleanup;
if(!needed || needed >= max_path_len)
goto cleanup;
- obuf = (malloc)(needed);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ obuf = malloc(needed);
if(!obuf)
goto cleanup;
if(wcstombs_s(&count, obuf, needed, fbuf, needed - 1))
#endif
cleanup:
- (free)(fbuf);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fbuf);
#ifndef _UNICODE
- (free)(ibuf);
- (free)(obuf);
+ /* !checksrc! disable BANNEDFUNC 2 */
+ free(ibuf);
+ free(obuf);
#endif
return *out ? true : false;
}
errno = _sopen_s(&result, target, oflag, _SH_DENYNO, pmode);
#endif
- (free)(fixed);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fixed);
return result;
}
errno = fopen_s(&result, target, mode);
#endif
- (free)(fixed);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fixed);
return result;
}
errno = freopen_s(&result, target, mode, fp);
#endif
- (free)(fixed);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fixed);
return result;
}
#endif
#endif
- (free)(fixed);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(fixed);
return result;
}
***************************************************************************/
/*
- * This file is 'mem-include-scan' clean, which means its memory allocations
- * are not tracked by the curl memory tracker memdebug, so they must not use
- * `CURLDEBUG` macro replacements in memdebug.h for free, malloc, etc. To avoid
- * these macro replacements, wrap the names in parentheses to call the original
- * versions: `ptr = (malloc)(123)`, `(free)(ptr)`, etc.
+ * Use system allocators to avoid infinite recursion when called by curl's
+ * memory tracker memdebug functions.
*/
#include "../curl_setup.h"
int str_w_len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS,
str_utf8, -1, NULL, 0);
if(str_w_len > 0) {
- str_w = (malloc)(str_w_len * sizeof(wchar_t));
+ /* !checksrc! disable BANNEDFUNC 1 */
+ str_w = malloc(str_w_len * sizeof(wchar_t));
if(str_w) {
if(MultiByteToWideChar(CP_UTF8, 0, str_utf8, -1, str_w,
str_w_len) == 0) {
- (free)(str_w);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(str_w);
return NULL;
}
}
int bytes = WideCharToMultiByte(CP_UTF8, 0, str_w, -1,
NULL, 0, NULL, NULL);
if(bytes > 0) {
- str_utf8 = (malloc)(bytes);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ str_utf8 = malloc(bytes);
if(str_utf8) {
if(WideCharToMultiByte(CP_UTF8, 0, str_w, -1, str_utf8, bytes,
NULL, NULL) == 0) {
- (free)(str_utf8);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(str_utf8);
return NULL;
}
}
*
* Allocated memory should be free'd with curlx_unicodefree().
*
- * Note: Because these are curlx functions their memory usage is not tracked
- * by the curl memory tracker memdebug. you will notice that curlx
- * function-like macros call free and strdup in parentheses, eg (strdup)(ptr),
- * and that is to ensure that the curl memdebug override macros do not replace
- * them.
+ * Use system allocators to avoid infinite recursion when called by curl's
+ * memory tracker memdebug functions.
*/
#if defined(UNICODE) && defined(_WIN32)
#else
-#define curlx_convert_UTF8_to_tchar(ptr) (strdup)(ptr)
-#define curlx_convert_tchar_to_UTF8(ptr) (strdup)(ptr)
+#ifdef _WIN32
+#define curlx_convert_UTF8_to_tchar(ptr) _strdup(ptr)
+#define curlx_convert_tchar_to_UTF8(ptr) _strdup(ptr)
+#else
+#define curlx_convert_UTF8_to_tchar(ptr) strdup(ptr)
+#define curlx_convert_tchar_to_UTF8(ptr) strdup(ptr)
+#endif
typedef union {
char *tchar_ptr;
#endif /* UNICODE && _WIN32 */
/* the purpose of this macro is to free() without being traced by memdebug */
-#define curlx_unicodefree(ptr) (free)(ptr)
+#define curlx_unicodefree(ptr) free(ptr)
#endif /* HEADER_CURL_MULTIBYTE_H */
#include "winapi.h"
#include "snprintf.h"
#include "strerr.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
#ifdef USE_WINSOCK
/* This is a helper function for curlx_strerror that converts Winsock error
#include "version_win32.h"
#include "warnless.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* This Unicode version struct works for VerifyVersionInfoW (OSVERSIONINFOEXW)
and RtlVerifyVersionInfo (RTLOSVERSIONINFOEXW) */
struct OUR_OSVERSIONINFOEXW {
#include "cw-out.h"
#include "cw-pause.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/**
* OVERALL DESIGN of this client writer
static struct cw_out_buf *cw_out_buf_create(cw_out_type otype)
{
- struct cw_out_buf *cwbuf = calloc(1, sizeof(*cwbuf));
+ struct cw_out_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf));
if(cwbuf) {
cwbuf->type = otype;
curlx_dyn_init(&cwbuf->b, DYN_PAUSE_BUFFER);
{
if(cwbuf) {
curlx_dyn_free(&cwbuf->b);
- free(cwbuf);
+ curlx_free(cwbuf);
}
}
#include "sendf.h"
#include "cw-pause.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* body dynbuf sizes */
#define CW_PAUSE_BUF_CHUNK (16 * 1024)
static struct cw_pause_buf *cw_pause_buf_create(int type, size_t buflen)
{
- struct cw_pause_buf *cwbuf = calloc(1, sizeof(*cwbuf));
+ struct cw_pause_buf *cwbuf = curlx_calloc(1, sizeof(*cwbuf));
if(cwbuf) {
cwbuf->type = type;
if(type & CLIENTWRITE_BODY)
{
if(cwbuf) {
Curl_bufq_free(&cwbuf->b);
- free(cwbuf);
+ curlx_free(cwbuf);
}
}
#include "progress.h"
#include "dict.h"
-/* The last 2 #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
-
#define DICT_MATCH "/MATCH:"
#define DICT_MATCH2 "/M:"
#define DICT_MATCH3 "/FIND:"
break;
}
- free(s); /* free the output string */
+ curlx_free(s); /* free the output string */
return result;
}
}
error:
- free(eword);
- free(path);
+ curlx_free(eword);
+ curlx_free(path);
return result;
}
#endif /* CURL_DISABLE_DICT */
#include <openssl/crypto.h>
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* DllMain() must only be defined for Windows DLL builds. */
#if defined(_WIN32) && !defined(CURL_STATICLIB)
#include "escape.h"
#include "urlapi-int.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define DNS_CLASS_IN 0x01
#ifndef CURL_DISABLE_VERBOSE_STRINGS
struct doh_request *doh_req = e;
curl_slist_free_all(doh_req->req_hds);
curlx_dyn_free(&doh_req->resp_body);
- free(e);
+ curlx_free(e);
}
}
*pmid = UINT32_MAX;
- doh_req = calloc(1, sizeof(*doh_req));
+ doh_req = curlx_calloc(1, sizeof(*doh_req));
if(!doh_req)
return CURLE_OUT_OF_MEMORY;
doh_req->dnstype = dnstype;
data->state.async.done = FALSE;
data->state.async.port = port;
data->state.async.ip_version = ip_version;
- data->state.async.hostname = strdup(hostname);
+ data->state.async.hostname = curlx_strdup(hostname);
if(!data->state.async.hostname)
return CURLE_OUT_OF_MEMORY;
/* start clean, consider allocating this struct on demand */
- data->state.async.doh = dohp = calloc(1, sizeof(struct doh_probes));
+ data->state.async.doh = dohp = curlx_calloc(1, sizeof(struct doh_probes));
if(!dohp)
return CURLE_OUT_OF_MEMORY;
qname ? qname : hostname, data->set.str[STRING_DOH],
data->multi,
&dohp->probe_resp[DOH_SLOT_HTTPS_RR].probe_mid);
- free(qname);
+ curlx_free(qname);
if(result)
goto error;
dohp->pending++;
addrtype = AF_INET;
}
- ai = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
+ ai = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen);
if(!ai) {
result = CURLE_OUT_OF_MEMORY;
break;
*hrr = NULL;
if(len <= 2)
return CURLE_BAD_FUNCTION_ARGUMENT;
- lhrr = calloc(1, sizeof(struct Curl_https_rrinfo));
+ lhrr = curlx_calloc(1, sizeof(struct Curl_https_rrinfo));
if(!lhrr)
return CURLE_OUT_OF_MEMORY;
lhrr->priority = doh_get16bit(cp, 0);
#include <nghttp2/nghttp2.h>
#endif /* USE_NGHTTP2 */
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static struct dynhds_entry *
entry_new(const char *name, size_t namelen,
DEBUGASSERT(name);
DEBUGASSERT(value);
- e = calloc(1, sizeof(*e) + namelen + valuelen + 2);
+ e = curlx_calloc(1, sizeof(*e) + namelen + valuelen + 2);
if(!e)
return NULL;
e->name = p = ((char *)e) + sizeof(*e);
char *p;
DEBUGASSERT(value);
- e2 = calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2);
+ e2 = curlx_calloc(1, sizeof(*e) + e->namelen + valuelen2 + 2);
if(!e2)
return NULL;
e2->name = p = ((char *)e2) + sizeof(*e2);
static void entry_free(struct dynhds_entry *e)
{
- free(e);
+ curlx_free(e);
}
void Curl_dynhds_init(struct dynhds *dynhds, size_t max_entries,
if(dynhds->max_entries && nallc > dynhds->max_entries)
nallc = dynhds->max_entries;
- nhds = calloc(nallc, sizeof(struct dynhds_entry *));
+ nhds = curlx_calloc(nallc, sizeof(struct dynhds_entry *));
if(!nhds)
goto out;
if(dynhds->hds) {
nghttp2_nv *Curl_dynhds_to_nva(struct dynhds *dynhds, size_t *pcount)
{
- nghttp2_nv *nva = calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len);
+ nghttp2_nv *nva = curlx_calloc(1, sizeof(nghttp2_nv) * dynhds->hds_len);
size_t i;
*pcount = 0;
#include "easy_lock.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* true globals -- for curl_global_init() and curl_global_cleanup() */
static unsigned int initialized;
static long easy_init_flags;
#ifdef DEBUGBUILD
if(getenv("CURL_GLOBAL_INIT"))
/* alloc data that will leak if *cleanup() is not called! */
- leakpointer = malloc(1);
+ leakpointer = curlx_malloc(1);
#endif
return CURLE_OK;
Curl_ssh_cleanup();
#ifdef DEBUGBUILD
- free(leakpointer);
+ curlx_free(leakpointer);
#endif
easy_init_flags = 0;
prev->next = nxt;
else
ev->list = nxt;
- free(m);
+ curlx_free(m);
infof(data, "socket cb: socket %" FMT_SOCKET_T " REMOVED", s);
}
else {
DEBUGASSERT(0);
}
else {
- m = malloc(sizeof(struct socketmonitor));
+ m = curlx_malloc(sizeof(struct socketmonitor));
if(m) {
m->next = ev->list;
m->socket.fd = s;
i = STRING_COPYPOSTFIELDS;
if(src->set.str[i]) {
if(src->set.postfieldsize == -1)
- dst->set.str[i] = strdup(src->set.str[i]);
+ dst->set.str[i] = curlx_strdup(src->set.str[i]);
else
/* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
dst->set.str[i] = Curl_memdup(src->set.str[i],
if(!GOOD_EASY_HANDLE(data))
goto fail;
- outcurl = calloc(1, sizeof(struct Curl_easy));
+ outcurl = curlx_calloc(1, sizeof(struct Curl_easy));
if(!outcurl)
goto fail;
#endif
if(data->state.url) {
- outcurl->state.url = strdup(data->state.url);
+ outcurl->state.url = curlx_strdup(data->state.url);
if(!outcurl->state.url)
goto fail;
outcurl->state.url_alloc = TRUE;
}
if(data->state.referer) {
- outcurl->state.referer = strdup(data->state.referer);
+ outcurl->state.referer = curlx_strdup(data->state.referer);
if(!outcurl->state.referer)
goto fail;
outcurl->state.referer_alloc = TRUE;
if(outcurl) {
#ifndef CURL_DISABLE_COOKIES
- free(outcurl->cookies);
+ curlx_free(outcurl->cookies);
#endif
curlx_dyn_free(&outcurl->state.headerb);
Curl_altsvc_cleanup(&outcurl->asi);
Curl_hsts_cleanup(&outcurl->hsts);
Curl_freeset(outcurl);
- free(outcurl);
+ curlx_free(outcurl);
}
return NULL;
#include "curlx/strparse.h"
#include "curl_printf.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* for ABI-compatibility with previous versions */
char *curl_escape(const char *string, int inlength)
{
length = (inlength ? (size_t)inlength : strlen(string));
if(!length)
- return strdup("");
+ return curlx_strdup("");
curlx_dyn_init(&d, length * 3 + 1);
DEBUGASSERT(ctrl >= REJECT_NADA); /* crash on TRUE/FALSE */
alloc = (length ? length : strlen(string));
- ns = malloc(alloc + 1);
+ ns = curlx_malloc(alloc + 1);
if(!ns)
return CURLE_OUT_OF_MEMORY;
the library's memory system */
void curl_free(void *p)
{
- free(p);
+ curlx_free(p);
}
/*
#include <stdlib.h>
#include <ares.h>
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
void r_freeaddrinfo(struct addrinfo *cahead)
{
struct addrinfo *canext;
for(ca = cahead; ca; ca = canext) {
canext = ca->ai_next;
- free(ca);
+ curlx_free(ca);
}
}
if((size_t)ai->ai_addrlen < ss_size)
continue;
- ca = malloc(sizeof(struct addrinfo) + ss_size + namelen);
+ ca = curlx_malloc(sizeof(struct addrinfo) + ss_size + namelen);
if(!ca) {
r_freeaddrinfo(cafirst);
return NULL;
#include "curlx/warnless.h"
#include "curl_range.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(_WIN32) || defined(MSDOS)
#define DOS_FILESYSTEM 1
#elif defined(__amigaos4__)
(void)key;
(void)klen;
file_cleanup(file);
- free(file);
+ curlx_free(file);
}
static CURLcode file_setup_connection(struct Curl_easy *data,
struct FILEPROTO *filep;
(void)conn;
/* allocate the FILE specific struct */
- filep = calloc(1, sizeof(*filep));
+ filep = curlx_calloc(1, sizeof(*filep));
if(!filep ||
Curl_meta_set(data, CURL_META_FILE_EASY, filep, file_easy_dtor))
return CURLE_OUT_OF_MEMORY;
file->path = real_path;
#endif
#endif
- free(file->freepath);
+ curlx_free(file->freepath);
file->freepath = real_path; /* free this when done */
file->fd = fd;
#ifndef CURL_DISABLE_FTP
#include "fileinfo.h"
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
struct fileinfo *Curl_fileinfo_alloc(void)
{
- return calloc(1, sizeof(struct fileinfo));
+ return curlx_calloc(1, sizeof(struct fileinfo));
}
void Curl_fileinfo_cleanup(struct fileinfo *finfo)
return;
curlx_dyn_free(&finfo->buf);
- free(finfo);
+ curlx_free(finfo);
}
#endif
#include "curlx/fopen.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define HTTPPOST_PTRNAME CURL_HTTPPOST_PTRNAME
#define HTTPPOST_FILENAME CURL_HTTPPOST_FILENAME
if((src->bufferlength > LONG_MAX) || (namelength > LONG_MAX))
/* avoid overflow in typecasts below */
return NULL;
- post = calloc(1, sizeof(struct curl_httppost));
+ post = curlx_calloc(1, sizeof(struct curl_httppost));
if(post) {
post->name = src->name;
post->namelength = (long)namelength;
struct FormInfo *parent_form_info)
{
struct FormInfo *form_info;
- form_info = calloc(1, sizeof(struct FormInfo));
+ form_info = curlx_calloc(1, sizeof(struct FormInfo));
if(!form_info)
return NULL;
if(value)
type = FILE_CONTENTTYPE_DEFAULT;
/* our contenttype is missing */
- form->contenttype = strdup(type);
+ form->contenttype = curlx_strdup(type);
if(!form->contenttype)
return CURL_FORMADD_MEMORY;
struct curl_httppost *next = c->next;
if(c->more)
free_chain(c->more);
- free(c);
+ curlx_free(c);
c = next;
}
}
/*
* We need to allocate the first struct to fill in.
*/
- first_form = calloc(1, sizeof(struct FormInfo));
+ first_form = curlx_calloc(1, sizeof(struct FormInfo));
if(!first_form)
return CURL_FORMADD_MEMORY;
if(!array_state)
avalue = va_arg(params, char *);
if(avalue) {
- curr->value = strdup(avalue);
+ curr->value = curlx_strdup(avalue);
if(!curr->value)
retval = CURL_FORMADD_MEMORY;
else {
if(curr->value) {
if(curr->flags & HTTPPOST_FILENAME) {
if(avalue) {
- char *fname = strdup(avalue);
+ char *fname = curlx_strdup(avalue);
if(!fname)
retval = CURL_FORMADD_MEMORY;
else {
form = AddFormInfo(fname, NULL, curr);
if(!form) {
- free(fname);
+ curlx_free(fname);
retval = CURL_FORMADD_MEMORY;
}
else {
}
else {
if(avalue) {
- curr->value = strdup(avalue);
+ curr->value = curlx_strdup(avalue);
if(!curr->value)
retval = CURL_FORMADD_MEMORY;
else {
if(curr->contenttype) {
if(curr->flags & HTTPPOST_FILENAME) {
if(avalue) {
- char *type = strdup(avalue);
+ char *type = curlx_strdup(avalue);
if(!type)
retval = CURL_FORMADD_MEMORY;
else {
form = AddFormInfo(NULL, type, curr);
if(!form) {
- free(type);
+ curlx_free(type);
retval = CURL_FORMADD_MEMORY;
}
else {
}
else {
if(avalue) {
- curr->contenttype = strdup(avalue);
+ curr->contenttype = curlx_strdup(avalue);
if(!curr->contenttype)
retval = CURL_FORMADD_MEMORY;
else
if(curr->showfilename)
retval = CURL_FORMADD_OPTION_TWICE;
else {
- curr->showfilename = strdup(avalue);
+ curr->showfilename = curlx_strdup(avalue);
if(!curr->showfilename)
retval = CURL_FORMADD_MEMORY;
else
now by the httppost linked list */
while(first_form) {
struct FormInfo *ptr = first_form->more;
- free(first_form);
+ curlx_free(first_form);
first_form = ptr;
}
curl_formfree(form->more);
if(!(form->flags & HTTPPOST_PTRNAME))
- free(form->name); /* free the name */
+ curlx_free(form->name); /* free the name */
if(!(form->flags &
(HTTPPOST_PTRCONTENTS|HTTPPOST_BUFFER|HTTPPOST_CALLBACK))
)
- free(form->contents); /* free the contents */
- free(form->contenttype); /* free the content type */
- free(form->showfilename); /* free the faked filename */
- free(form); /* free the struct */
+ curlx_free(form->contents); /* free the contents */
+ curlx_free(form->contenttype); /* free the content type */
+ curlx_free(form->showfilename); /* free the faked filename */
+ curlx_free(form); /* free the struct */
form = next;
} while(form); /* continue */
}
if(!zname)
return CURLE_OUT_OF_MEMORY;
res = curl_mime_name(part, zname);
- free(zname);
+ curlx_free(zname);
return res;
}
#include "curlx/strerr.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
return CURLE_OUT_OF_MEMORY;
result = Curl_pp_sendf(data, &ftpc->pp, "%s", cmd);
- free(cmd);
+ curlx_free(cmd);
if(!result)
ftp_state(data, ftpc, FTP_LIST);
not the ftp host. */
#ifndef CURL_DISABLE_PROXY
if(conn->bits.tunnel_proxy || conn->bits.socksproxy)
- *newhostp = strdup(conn->host.name);
+ *newhostp = curlx_strdup(conn->host.name);
else
#endif
if(!Curl_conn_get_ip_info(data, conn, FIRSTSOCKET, &is_ipv6, &ipquad) &&
*ipquad.remote_ip)
- *newhostp = strdup(ipquad.remote_ip);
+ *newhostp = curlx_strdup(ipquad.remote_ip);
else {
/* failed to get the remote_ip of the DATA connection */
failf(data, "unable to get peername of DATA connection");
/* postponed address resolution in case of tcp fastopen */
if(conn->bits.tcp_fastopen && !conn->bits.reuse && !newhost[0]) {
- free(newhost);
+ curlx_free(newhost);
result = ftp_control_addr_dup(data, &newhost);
if(result)
goto error;
if(result) {
if(ftpc->count1 == 0 && ftpcode == 229) {
- free(newhost);
+ curlx_free(newhost);
return ftp_epsv_disable(data, ftpc, conn);
}
/* this just dumps information about this second connection */
ftp_pasv_verbose(data, dns->addr, newhost, connectport);
- free(conn->secondaryhostname);
+ curlx_free(conn->secondaryhostname);
conn->secondary_port = newport;
- conn->secondaryhostname = strdup(newhost);
+ conn->secondaryhostname = curlx_strdup(newhost);
if(!conn->secondaryhostname) {
result = CURLE_OUT_OF_MEMORY;
goto error;
ftp_state(data, ftpc, FTP_STOP); /* this phase is completed */
error:
- free(newhost);
+ curlx_free(newhost);
return result;
}
if(!ftpc->server_os && dir[0] != '/') {
result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SYST");
if(result) {
- free(dir);
+ curlx_free(dir);
return result;
}
}
- free(ftpc->entrypath);
+ curlx_free(ftpc->entrypath);
ftpc->entrypath = dir; /* remember this */
infof(data, "Entry path is '%s'", ftpc->entrypath);
/* also save it where getinfo can access it: */
- free(data->state.most_recent_ftp_entrypath);
- data->state.most_recent_ftp_entrypath = strdup(ftpc->entrypath);
+ curlx_free(data->state.most_recent_ftp_entrypath);
+ data->state.most_recent_ftp_entrypath = curlx_strdup(ftpc->entrypath);
if(!data->state.most_recent_ftp_entrypath)
return CURLE_OUT_OF_MEMORY;
/* Force OS400 name format 1. */
result = Curl_pp_sendf(data, &ftpc->pp, "%s", "SITE NAMEFMT 1");
if(result) {
- free(os);
+ curlx_free(os);
return result;
}
/* remember target server OS */
- free(ftpc->server_os);
+ curlx_free(ftpc->server_os);
ftpc->server_os = os;
ftp_state(data, ftpc, FTP_NAMEFMT);
break;
}
/* Nothing special for the target server. */
/* remember target server OS */
- free(ftpc->server_os);
+ curlx_free(ftpc->server_os);
ftpc->server_os = os;
}
else {
* the error path) */
ftpc->ctl_valid = FALSE; /* mark control connection as bad */
connclose(conn, "FTP: out of memory!"); /* mark for connection closure */
- free(ftpc->prevpath);
+ curlx_free(ftpc->prevpath);
ftpc->prevpath = NULL; /* no path remembering */
}
else { /* remember working directory for connection reuse */
else {
size_t pathLen = strlen(ftpc->rawpath);
- free(ftpc->prevpath);
+ curlx_free(ftpc->prevpath);
if(!ftpc->cwdfail) {
if(data->set.ftp_filemethod == FTPFILE_NOCWD)
struct ftp_wc *ftpwc = ptr;
if(ftpwc && ftpwc->parser)
Curl_ftp_parselist_data_free(&ftpwc->parser);
- free(ftpwc);
+ curlx_free(ftpwc);
}
static CURLcode init_wc_data(struct Curl_easy *data,
wildcard->state = CURLWC_CLEAN;
return ftp_parse_url_path(data, ftpc, ftp);
}
- wildcard->pattern = strdup(last_slash);
+ wildcard->pattern = curlx_strdup(last_slash);
if(!wildcard->pattern)
return CURLE_OUT_OF_MEMORY;
last_slash[0] = '\0'; /* cut file from path */
}
else { /* there is only 'wildcard pattern' or nothing */
if(path[0]) {
- wildcard->pattern = strdup(path);
+ wildcard->pattern = curlx_strdup(path);
if(!wildcard->pattern)
return CURLE_OUT_OF_MEMORY;
path[0] = '\0';
resources for wildcard transfer */
/* allocate ftp protocol specific wildcard data */
- ftpwc = calloc(1, sizeof(struct ftp_wc));
+ ftpwc = curlx_calloc(1, sizeof(struct ftp_wc));
if(!ftpwc) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
goto fail;
}
- wildcard->path = strdup(ftp->path);
+ wildcard->path = curlx_strdup(ftp->path);
if(!wildcard->path) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
fail:
if(ftpwc) {
Curl_ftp_parselist_data_free(&ftpwc->parser);
- free(ftpwc);
+ curlx_free(ftpwc);
}
Curl_safefree(wildcard->pattern);
wildcard->dtor = ZERO_NULL;
return CURLE_OUT_OF_MEMORY;
/* switch default ftp->path and tmp_path */
- free(ftp->pathalloc);
+ curlx_free(ftp->pathalloc);
ftp->pathalloc = ftp->path = tmp_path;
infof(data, "Wildcard - START of \"%s\"", finfo->filename);
if(dirlen == 0)
dirlen = 1;
- ftpc->dirs = calloc(1, sizeof(ftpc->dirs[0]));
+ ftpc->dirs = curlx_calloc(1, sizeof(ftpc->dirs[0]));
if(!ftpc->dirs)
return CURLE_OUT_OF_MEMORY;
return CURLE_URL_MALFORMAT;
if(dirAlloc) {
- ftpc->dirs = calloc(dirAlloc, sizeof(ftpc->dirs[0]));
+ ftpc->dirs = curlx_calloc(dirAlloc, sizeof(ftpc->dirs[0]));
if(!ftpc->dirs)
return CURLE_OUT_OF_MEMORY;
(void)key;
(void)klen;
Curl_safefree(ftp->pathalloc);
- free(ftp);
+ curlx_free(ftp);
}
static void ftp_conn_dtor(void *key, size_t klen, void *entry)
Curl_safefree(ftpc->prevpath);
Curl_safefree(ftpc->server_os);
Curl_pp_disconnect(&ftpc->pp);
- free(ftpc);
+ curlx_free(ftpc);
}
static void type_url_check(struct Curl_easy *data, struct FTP *ftp)
CURLcode result = CURLE_OK;
struct ftp_conn *ftpc;
- ftp = calloc(1, sizeof(*ftp));
+ ftp = curlx_calloc(1, sizeof(*ftp));
if(!ftp ||
Curl_meta_set(data, CURL_META_FTP_EASY, ftp, ftp_easy_dtor))
return CURLE_OUT_OF_MEMORY;
- ftpc = calloc(1, sizeof(*ftpc));
+ ftpc = curlx_calloc(1, sizeof(*ftpc));
if(!ftpc ||
Curl_conn_meta_set(conn, CURL_META_FTP_CONN, ftpc, ftp_conn_dtor))
return CURLE_OUT_OF_MEMORY;
/* clone connection related data that is FTP specific */
if(data->set.str[STRING_FTP_ACCOUNT]) {
- ftpc->account = strdup(data->set.str[STRING_FTP_ACCOUNT]);
+ ftpc->account = curlx_strdup(data->set.str[STRING_FTP_ACCOUNT]);
if(!ftpc->account) {
Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
return CURLE_OUT_OF_MEMORY;
}
if(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]) {
ftpc->alternative_to_user =
- strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
+ curlx_strdup(data->set.str[STRING_FTP_ALTERNATIVE_TO_USER]);
if(!ftpc->alternative_to_user) {
Curl_safefree(ftpc->account);
Curl_conn_meta_remove(conn, CURL_META_FTP_CONN);
#include "multiif.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
typedef enum {
PL_UNIX_TOTALSIZE = 0,
PL_UNIX_FILETYPE,
DEBUGASSERT(wc->ftpwc == NULL);
Curl_llist_destroy(&wc->filelist, NULL);
- free(wc->path);
+ curlx_free(wc->path);
wc->path = NULL;
- free(wc->pattern);
+ curlx_free(wc->pattern);
wc->pattern = NULL;
wc->state = CURLWC_INIT;
- free(wc);
+ curlx_free(wc);
*wcp = NULL;
}
struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void)
{
- return calloc(1, sizeof(struct ftp_parselist_data));
+ return curlx_calloc(1, sizeof(struct ftp_parselist_data));
}
struct ftp_parselist_data *parser = *parserp;
if(parser)
Curl_fileinfo_cleanup(parser->file_data);
- free(parser);
+ curlx_free(parser);
*parserp = NULL;
}
#include "curl_setup.h"
#include <curl/curl.h>
-#include "curl_memory.h"
-
-#include "memdebug.h"
static char *GetEnv(const char *variable)
{
const DWORD max = 32768; /* max env var size from MSCRT source */
for(;;) {
- tmp = realloc(buf, rc);
+ tmp = curlx_realloc(buf, rc);
if(!tmp) {
- free(buf);
+ curlx_free(buf);
return NULL;
}
Since getenv does not make that distinction we ignore it as well. */
rc = GetEnvironmentVariableA(variable, buf, bufsize);
if(!rc || rc == bufsize || rc > max) {
- free(buf);
+ curlx_free(buf);
return NULL;
}
}
#else
char *env = getenv(variable);
- return (env && env[0]) ? strdup(env) : NULL;
+ return (env && env[0]) ? curlx_strdup(env) : NULL;
#endif
}
#include "progress.h"
#include "curlx/strparse.h"
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Initialize statistical and informational data.
*
info->httpauthpicked = 0;
info->numconnects = 0;
- free(info->contenttype);
+ curlx_free(info->contenttype);
info->contenttype = NULL;
- free(info->wouldredirect);
+ curlx_free(info->wouldredirect);
info->wouldredirect = NULL;
memset(&info->primary, 0, sizeof(info->primary));
case CURLINFO_FTP_ENTRY_PATH:
/* Return the entrypath string from the most recent connection.
This pointer was copied from the connectdata structure by FTP.
- The actual string may be free()ed by subsequent libcurl calls so
+ The actual string may be freed by subsequent libcurl calls so
it must be copied to a safer area before the next libcurl call.
Callers must never free it themselves. */
*param_charp = data->state.most_recent_ftp_entrypath;
#include "escape.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Forward declarations.
*/
if(query)
gopherpath = curl_maprintf("%s?%s", path, query);
else
- gopherpath = strdup(path);
+ gopherpath = curlx_strdup(path);
if(!gopherpath)
return CURLE_OUT_OF_MEMORY;
if(strlen(gopherpath) <= 2) {
buf = "";
buf_len = 0;
- free(gopherpath);
+ curlx_free(gopherpath);
}
else {
char *newp;
/* ... and finally unescape */
result = Curl_urldecode(newp, 0, &buf_alloc, &buf_len, REJECT_ZERO);
- free(gopherpath);
+ curlx_free(gopherpath);
if(result)
return result;
buf = buf_alloc;
}
}
- free(buf_alloc);
+ curlx_free(buf_alloc);
if(!result)
result = Curl_xfer_send(data, "\r\n", 2, FALSE, &nwritten);
#include "hash.h"
#include "llist.h"
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
/* random patterns for API verification */
#ifdef DEBUGBUILD
struct Curl_hash_element *he;
/* allocate the struct plus memory after it to store the key */
- he = malloc(sizeof(struct Curl_hash_element) + key_len);
+ he = curlx_malloc(sizeof(struct Curl_hash_element) + key_len);
if(he) {
he->next = NULL;
/* copy the key */
struct Curl_hash_element *he)
{
hash_elem_clear_ptr(h, he);
- free(he);
+ curlx_free(he);
}
static void hash_elem_unlink(struct Curl_hash *h,
DEBUGASSERT(h->slots);
DEBUGASSERT(h->init == HASHINIT);
if(!h->table) {
- h->table = calloc(h->slots, sizeof(struct Curl_hash_element *));
+ h->table = curlx_calloc(h->slots, sizeof(struct Curl_hash_element *));
if(!h->table)
return NULL; /* OOM */
}
#include "headers.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_HEADERS_API)
/* Generate the curl_header struct for the user. This function MUST assign all
return CURLE_TOO_LARGE;
}
- hs = calloc(1, sizeof(*hs) + hlen);
+ hs = curlx_calloc(1, sizeof(*hs) + hlen);
if(!hs)
return CURLE_OUT_OF_MEMORY;
memcpy(hs->buffer, header, hlen);
}
else {
failf(data, "Invalid response header");
- free(hs);
+ curlx_free(hs);
}
return result;
}
for(e = Curl_llist_head(&data->state.httphdrs); e; e = n) {
struct Curl_header_store *hs = Curl_node_elem(e);
n = Curl_node_next(e);
- free(hs);
+ curlx_free(hs);
}
headers_reset(data);
return CURLE_OK;
#include <curl/curl.h>
#include "curl_hmac.h"
-#include "curl_memory.h"
#include "curlx/warnless.h"
-/* The last #include file should be: */
-#include "memdebug.h"
-
/*
* Generic HMAC algorithm.
*
/* Create HMAC context. */
i = sizeof(*ctxt) + 2 * hashparams->ctxtsize + hashparams->resultlen;
- ctxt = malloc(i);
+ ctxt = curlx_malloc(i);
if(!ctxt)
return ctxt;
return ctxt;
fail:
- free(ctxt);
+ curlx_free(ctxt);
return NULL;
}
hashparams->hfinal(output, ctxt->hashctxt1);
hashparams->hupdate(ctxt->hashctxt2, output, hashparams->resultlen);
hashparams->hfinal(output, ctxt->hashctxt2);
- free(ctxt);
+ curlx_free(ctxt);
return 0;
}
#include "easy_lock.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(CURLRES_SYNCH) && \
defined(HAVE_ALARM) && \
defined(SIGALRM) && \
struct Curl_addrinfo **nodes;
infof(data, "Shuffling %i addresses", num_addrs);
- nodes = malloc(num_addrs*sizeof(*nodes));
+ nodes = curlx_malloc(num_addrs*sizeof(*nodes));
if(nodes) {
int i;
unsigned int *rnd;
nodes[i] = nodes[i-1]->ai_next;
}
- rnd = malloc(rnd_size);
+ rnd = curlx_malloc(rnd_size);
if(rnd) {
/* Fisher-Yates shuffle */
if(Curl_rand(data, (unsigned char *)rnd, rnd_size) == CURLE_OK) {
nodes[num_addrs-1]->ai_next = NULL;
*addr = nodes[0];
}
- free(rnd);
+ curlx_free(rnd);
}
else
result = CURLE_OUT_OF_MEMORY;
- free(nodes);
+ curlx_free(nodes);
}
else
result = CURLE_OUT_OF_MEMORY;
hostlen = strlen(hostname);
/* Create a new cache entry */
- dns = calloc(1, sizeof(struct Curl_dns_entry) + hostlen);
+ dns = curlx_calloc(1, sizeof(struct Curl_dns_entry) + hostlen);
if(!dns)
return NULL;
struct sockaddr_in6 sa6;
unsigned char ipv6[16];
unsigned short port16 = (unsigned short)(port & 0xffff);
- ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
+ ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
if(!ca)
return NULL;
return NULL;
memcpy(&sa.sin_addr, &ipv4, sizeof(ipv4));
- ca = calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
+ ca = curlx_calloc(1, sizeof(struct Curl_addrinfo) + ss_size + hostlen + 1);
if(!ca)
return NULL;
ca->ai_flags = 0;
#ifdef USE_HTTPSRR
if(dns->hinfo) {
Curl_httpsrr_cleanup(dns->hinfo);
- free(dns->hinfo);
+ curlx_free(dns->hinfo);
}
#endif
- free(dns);
+ curlx_free(dns);
}
/*
#include "curl_share.h"
#include "url.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef CURLRES_SYNCH
*/
int h_errnop;
- buf = calloc(1, CURL_HOSTENT_SIZE);
+ buf = curlx_calloc(1, CURL_HOSTENT_SIZE);
if(!buf)
return NULL; /* major failure */
/*
* Since we do not know how big buffer this particular lookup required,
* we cannot realloc down the huge alloc without doing closer analysis of
* the returned data. Thus, we always use CURL_HOSTENT_SIZE for every
- * name lookup. Fixing this would require an extra malloc() and then
- * calling Curl_addrinfo_copy() that subsequent realloc()s down the new
+ * name lookup. Fixing this would require an extra allocation and then
+ * calling Curl_addrinfo_copy() that subsequent reallocation down the new
* memory area to the actually used amount.
*/
}
#endif /* HAVE_...BYNAME_R_5 || HAVE_...BYNAME_R_6 || HAVE_...BYNAME_R_3 */
{
h = NULL; /* set return code to NULL */
- free(buf);
+ curlx_free(buf);
}
#else /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) ||
HAVE_GETHOSTBYNAME_R */
ai = Curl_he2ai(h, port);
if(buf) /* used a *_r() function */
- free(buf);
+ curlx_free(buf);
}
#endif
#include "curlx/inet_pton.h"
#include "connect.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef CURLRES_SYNCH
#ifdef DEBUG_ADDRINFO
#include "strdup.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define MAX_HSTS_LINE 4095
#define MAX_HSTS_HOSTLEN 2048
#define MAX_HSTS_DATELEN 256
struct hsts *Curl_hsts_init(void)
{
- struct hsts *h = calloc(1, sizeof(struct hsts));
+ struct hsts *h = curlx_calloc(1, sizeof(struct hsts));
if(h) {
Curl_llist_init(&h->list, NULL);
}
static void hsts_free(struct stsentry *e)
{
- free(CURL_UNCONST(e->host));
- free(e);
+ curlx_free(CURL_UNCONST(e->host));
+ curlx_free(e);
}
void Curl_hsts_cleanup(struct hsts **hp)
n = Curl_node_next(e);
hsts_free(sts);
}
- free(h->filename);
- free(h);
+ curlx_free(h->filename);
+ curlx_free(h);
*hp = NULL;
}
}
--hlen;
if(hlen) {
char *duphost;
- struct stsentry *sts = calloc(1, sizeof(struct stsentry));
+ struct stsentry *sts = curlx_calloc(1, sizeof(struct stsentry));
if(!sts)
return CURLE_OUT_OF_MEMORY;
duphost = Curl_memdup0(hostname, hlen);
if(!duphost) {
- free(sts);
+ curlx_free(sts);
return CURLE_OUT_OF_MEMORY;
}
if(result && tempstore)
unlink(tempstore);
}
- free(tempstore);
+ curlx_free(tempstore);
skipsave:
if(data->set.hsts_write) {
/* if there is a write callback */
/* we need a private copy of the filename so that the hsts cache file
name survives an easy handle reset */
- free(h->filename);
- h->filename = strdup(file);
+ curlx_free(h->filename);
+ h->filename = curlx_strdup(file);
if(!h->filename)
return CURLE_OUT_OF_MEMORY;
#include "curl_ctype.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Forward declarations.
*/
/*
* Strip off leading and trailing whitespace from the value in the given HTTP
- * header line and return a strdup()ed copy in 'valp' - returns an empty
+ * header line and return a strdup-ed copy in 'valp' - returns an empty
* string if the header value consists entirely of whitespace.
*
* If the header is provided as "name;", ending with a semicolon, it returns a
/*
* Strip off leading and trailing whitespace from the value in the given HTTP
- * header line and return a strdup()ed copy in 'valp' - returns an empty
+ * header line and return a strdup-ed copy in 'valp' - returns an empty
* string if the header value consists entirely of whitespace.
*
* This function MUST be used after the header has already been confirmed to
goto fail;
}
- free(*userp);
+ curlx_free(*userp);
*userp = curl_maprintf("%sAuthorization: Basic %s\r\n",
proxy ? "Proxy-" : "",
authorization);
- free(authorization);
+ curlx_free(authorization);
if(!*userp) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
}
fail:
- free(out);
+ curlx_free(out);
return result;
}
CURLcode result = CURLE_OK;
userp = &data->state.aptr.userpwd;
- free(*userp);
+ curlx_free(*userp);
*userp = curl_maprintf("Authorization: Bearer %s\r\n",
data->set.str[STRING_BEARER]);
/* In case this is GSS auth, the newurl field is already allocated so
we must make sure to free it before allocating a new one. As figured
out in bug #2284386 */
- free(data->req.newurl);
- data->req.newurl = strdup(data->state.url); /* clone URL */
+ curlx_free(data->req.newurl);
+ data->req.newurl = curlx_strdup(data->state.url); /* clone URL */
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
}
we did not try HEAD or GET */
if((data->state.httpreq != HTTPREQ_GET) &&
(data->state.httpreq != HTTPREQ_HEAD)) {
- data->req.newurl = strdup(data->state.url); /* clone URL */
+ data->req.newurl = curlx_strdup(data->state.url); /* clone URL */
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
data->state.authhost.done = TRUE;
curlnegotiate *negstate = proxy ? &conn->proxy_negotiate_state :
&conn->http_negotiate_state;
if(!result) {
- free(data->req.newurl);
- data->req.newurl = strdup(data->state.url);
+ curlx_free(data->req.newurl);
+ data->req.newurl = curlx_strdup(data->state.url);
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
data->state.authproblem = FALSE;
/* the URL could not be parsed for some reason, but since this is FAKE
mode, just duplicate the field as-is */
- follow_url = strdup(newurl);
+ follow_url = curlx_strdup(newurl);
if(!follow_url)
return CURLE_OUT_OF_MEMORY;
}
uc = curl_url_get(data->state.uh, CURLUPART_PORT, &portnum,
CURLU_DEFAULT_PORT);
if(uc) {
- free(follow_url);
+ curlx_free(follow_url);
return Curl_uc_to_curlcode(uc);
}
p = portnum;
curlx_str_number(&p, &value, 0xffff);
port = (int)value;
- free(portnum);
+ curlx_free(portnum);
}
if(port != data->info.conn_remote_port) {
infof(data, "Clear auth, redirects to port from %u to %u",
const struct Curl_handler *p;
uc = curl_url_get(data->state.uh, CURLUPART_SCHEME, &scheme, 0);
if(uc) {
- free(follow_url);
+ curlx_free(follow_url);
return Curl_uc_to_curlcode(uc);
}
data->info.conn_scheme, scheme);
clear = TRUE;
}
- free(scheme);
+ curlx_free(scheme);
}
if(clear) {
Curl_safefree(data->state.aptr.user);
with the user-agent string specified, we erase the previously made string
here. */
if(Curl_checkheaders(data, STRCONST("User-Agent"))) {
- free(data->state.aptr.uagent);
+ curlx_free(data->state.aptr.uagent);
data->state.aptr.uagent = NULL;
}
return CURLE_OK;
if(!data->state.this_is_a_follow) {
/* Free to avoid leaking memory on multiple requests */
- free(data->state.first_host);
+ curlx_free(data->state.first_host);
- data->state.first_host = strdup(conn->host.name);
+ data->state.first_host = curlx_strdup(conn->host.name);
if(!data->state.first_host)
return CURLE_OUT_OF_MEMORY;
return result;
if(!*cookiehost)
/* ignore empty data */
- free(cookiehost);
+ curlx_free(cookiehost);
else {
/* If the host begins with '[', we start searching for the port after
the bracket has been closed */
if(colon)
*colon = 0; /* The host must not include an embedded port number */
}
- free(aptr->cookiehost);
+ curlx_free(aptr->cookiehost);
aptr->cookiehost = cookiehost;
}
#endif
/* target or URL */
result = curlx_dyn_add(r, data->set.str[STRING_TARGET] ?
data->set.str[STRING_TARGET] : url);
- free(url);
+ curlx_free(url);
if(result)
return result;
/* Convert the form structure into a mime structure, then keep
the conversion */
if(!data->state.formp) {
- data->state.formp = calloc(1, sizeof(curl_mimepart));
+ data->state.formp = curlx_calloc(1, sizeof(curl_mimepart));
if(!data->state.formp)
return CURLE_OUT_OF_MEMORY;
Curl_mime_cleanpart(data->state.formp);
if(((httpreq == HTTPREQ_GET) || (httpreq == HTTPREQ_HEAD)) &&
!Curl_checkheaders(data, STRCONST("Range"))) {
/* if a line like this was already allocated, free the previous one */
- free(data->state.aptr.rangeline);
+ curlx_free(data->state.aptr.rangeline);
data->state.aptr.rangeline = curl_maprintf("Range: bytes=%s\r\n",
data->state.range);
if(!data->state.aptr.rangeline)
!Curl_checkheaders(data, STRCONST("Content-Range"))) {
curl_off_t req_clen = Curl_creader_total_length(data);
/* if a line like this was already allocated, free the previous one */
- free(data->state.aptr.rangeline);
+ curlx_free(data->state.aptr.rangeline);
if(data->set.set_resume_from < 0) {
/* Upload resume was asked for, but we do not know the size of the
return result;
result = curlx_dyn_addf(req, "%s%s", sep, value);
sep = ", ";
- free(value);
+ curlx_free(value);
break; /* leave, having added 1st one */
}
}
}
result = Curl_http_output_auth(data, data->conn, method, httpreq,
(pq ? pq : data->state.up.path), FALSE);
- free(pq);
+ curlx_free(pq);
}
if(result)
goto out;
return CURLE_OUT_OF_MEMORY;
if(!*contenttype)
/* ignore empty data */
- free(contenttype);
+ curlx_free(contenttype);
else {
- free(data->info.contenttype);
+ curlx_free(data->info.contenttype);
data->info.contenttype = contenttype;
}
return CURLE_OK;
if(!*location ||
(data->req.location && !strcmp(data->req.location, location))) {
/* ignore empty header, or exact repeat of a previous one */
- free(location);
+ curlx_free(location);
return CURLE_OK;
}
else {
/* has value and is not an exact repeat */
if(data->req.location) {
failf(data, "Multiple Location headers");
- free(location);
+ curlx_free(location);
return CURLE_WEIRD_SERVER_REPLY;
}
data->req.location = location;
data->set.http_follow_mode) {
CURLcode result;
DEBUGASSERT(!data->req.newurl);
- data->req.newurl = strdup(data->req.location); /* clone */
+ data->req.newurl = curlx_strdup(data->req.location); /* clone */
if(!data->req.newurl)
return CURLE_OUT_OF_MEMORY;
CURLcode result = auth ? CURLE_OK : CURLE_OUT_OF_MEMORY;
if(!result) {
result = Curl_http_input_auth(data, TRUE, auth);
- free(auth);
+ curlx_free(auth);
}
return result;
}
negdata->havenoauthpersist = TRUE;
infof(data, "Negotiate: noauthpersist -> %d, header part: %s",
negdata->noauthpersist, persistentauth);
- free(persistentauth);
+ curlx_free(persistentauth);
}
}
#endif
result = CURLE_OUT_OF_MEMORY;
else {
result = Curl_http_input_auth(data, FALSE, auth);
- free(auth);
+ curlx_free(auth);
}
}
return result;
data->state.disableexpect = TRUE;
Curl_req_abort_sending(data);
DEBUGASSERT(!data->req.newurl);
- data->req.newurl = strdup(data->state.url);
+ data->req.newurl = curlx_strdup(data->state.url);
if(!data->req.newurl) {
result = CURLE_OUT_OF_MEMORY;
goto out;
DEBUGASSERT(method && m_len);
- req = calloc(1, sizeof(*req) + m_len);
+ req = curlx_calloc(1, sizeof(*req) + m_len);
if(!req)
goto out;
#if defined(__GNUC__) && __GNUC__ >= 13
}
req->authority = curlx_dyn_ptr(&buf);
out:
- free(host);
- free(port);
+ curlx_free(host);
+ curlx_free(port);
if(result)
curlx_dyn_free(&buf);
return result;
result = CURLE_OK;
out:
- free(path);
- free(query);
+ curlx_free(path);
+ curlx_free(query);
if(result)
curlx_dyn_free(&buf);
return result;
DEBUGASSERT(method && m_len);
- req = calloc(1, sizeof(*req) + m_len);
+ req = curlx_calloc(1, sizeof(*req) + m_len);
if(!req)
goto out;
memcpy(req->method, method, m_len);
if(uc && uc != CURLUE_NO_SCHEME)
goto out;
if(!req->scheme && scheme_default) {
- req->scheme = strdup(scheme_default);
+ req->scheme = curlx_strdup(scheme_default);
if(!req->scheme)
goto out;
}
void Curl_http_req_free(struct httpreq *req)
{
if(req) {
- free(req->scheme);
- free(req->authority);
- free(req->path);
+ curlx_free(req->scheme);
+ curlx_free(req->authority);
+ curlx_free(req->path);
Curl_dynhds_free(&req->headers);
Curl_dynhds_free(&req->trailers);
- free(req);
+ curlx_free(req);
}
}
struct http_resp *resp;
CURLcode result = CURLE_OUT_OF_MEMORY;
- resp = calloc(1, sizeof(*resp));
+ resp = curlx_calloc(1, sizeof(*resp));
if(!resp)
goto out;
resp->status = status;
if(description) {
- resp->description = strdup(description);
+ resp->description = curlx_strdup(description);
if(!resp->description)
goto out;
}
void Curl_http_resp_free(struct http_resp *resp)
{
if(resp) {
- free(resp->description);
+ curlx_free(resp->description);
Curl_dynhds_free(&resp->headers);
Curl_dynhds_free(&resp->trailers);
if(resp->prev)
Curl_http_resp_free(resp->prev);
- free(resp);
+ curlx_free(resp);
}
}
#include "http1.h"
#include "urlapi-int.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define H1_MAX_URL_LEN (8*1024)
#include "curlx/warnless.h"
#include "headers.h"
-/* The last 3 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if (NGHTTP2_VERSION_NUM < 0x010c00)
#error too old nghttp2 version, upgrade!
#endif
Curl_uint32_hash_destroy(&ctx->streams);
memset(ctx, 0, sizeof(*ctx));
}
- free(ctx);
+ curlx_free(ctx);
}
static void cf_h2_ctx_close(struct cf_h2_ctx *ctx)
struct h2_stream_ctx *stream;
(void)ctx;
- stream = calloc(1, sizeof(*stream));
+ stream = curlx_calloc(1, sizeof(*stream));
if(!stream)
return NULL;
{
size_t i;
for(i = 0; i < stream->push_headers_used; i++)
- free(stream->push_headers[i]);
+ curlx_free(stream->push_headers[i]);
Curl_safefree(stream->push_headers);
stream->push_headers_used = 0;
}
Curl_h1_req_parse_free(&stream->h1);
Curl_dynhds_free(&stream->resp_trailers);
free_push_headers(stream);
- free(stream);
+ curlx_free(stream);
}
static void h2_stream_hash_free(unsigned int id, void *stream)
return rc;
if(data->state.url_alloc)
- free(data->state.url);
+ curlx_free(data->state.url);
data->state.url_alloc = TRUE;
data->state.url = url;
return 0;
stream_id, NGHTTP2_PROTOCOL_ERROR);
rc = NGHTTP2_ERR_CALLBACK_FAILURE;
}
- free(check);
+ curlx_free(check);
if(rc)
return rc;
}
if(!stream->push_headers) {
stream->push_headers_alloc = 10;
- stream->push_headers = malloc(stream->push_headers_alloc *
- sizeof(char *));
+ stream->push_headers = curlx_malloc(stream->push_headers_alloc *
+ sizeof(char *));
if(!stream->push_headers)
return NGHTTP2_ERR_CALLBACK_FAILURE;
stream->push_headers_used = 0;
return NGHTTP2_ERR_CALLBACK_FAILURE;
}
stream->push_headers_alloc *= 2;
- headp = realloc(stream->push_headers,
- stream->push_headers_alloc * sizeof(char *));
+ headp = curlx_realloc(stream->push_headers,
+ stream->push_headers_alloc * sizeof(char *));
if(!headp) {
free_push_headers(stream);
return NGHTTP2_ERR_CALLBACK_FAILURE;
"Upgrade: %s\r\n"
"HTTP2-Settings: %s\r\n",
NGHTTP2_CLEARTEXT_PROTO_VERSION_ID, base64);
- free(base64);
+ curlx_free(base64);
k->upgr101 = UPGR101_H2;
data->conn->bits.upgrade_in_progress = TRUE;
CURLcode result = CURLE_OUT_OF_MEMORY;
DEBUGASSERT(data->conn);
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx)
goto out;
cf_h2_ctx_init(ctx, via_h1_upgrade);
CURLcode result = CURLE_OUT_OF_MEMORY;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx)
goto out;
cf_h2_ctx_init(ctx, via_h1_upgrade);
#include <time.h>
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#include "slist.h"
#define HMAC_SHA256(k, kl, d, dl, o) \
if(result)
return result;
- free(curr->data);
+ curlx_free(curr->data);
curr->data = curlx_dyn_ptr(&buf);
curr->next = next->next;
- free(next->data);
- free(next);
+ curlx_free(next->data);
+ curlx_free(next);
}
else {
curr = curr->next;
if(fullhost)
head = Curl_slist_append_nodup(NULL, fullhost);
if(!head) {
- free(fullhost);
+ curlx_free(fullhost);
goto fail;
}
}
;
if(!*ptr && ptr != sep + 1) /* a value of whitespace only */
continue;
- dupdata = strdup(l->data);
+ dupdata = curlx_strdup(l->data);
if(!dupdata)
goto fail;
dupdata[sep - l->data] = ':';
tmp_head = Curl_slist_append_nodup(head, dupdata);
if(!tmp_head) {
- free(dupdata);
+ curlx_free(dupdata);
goto fail;
}
head = tmp_head;
Curl_strntoupper(&auth_headers[sizeof("Authorization: ") - 1],
curlx_str(&provider0), curlx_strlen(&provider0));
- free(data->state.aptr.userpwd);
+ curlx_free(data->state.aptr.userpwd);
data->state.aptr.userpwd = auth_headers;
data->state.authhost.done = TRUE;
result = CURLE_OK;
curlx_dyn_free(&canonical_path);
curlx_dyn_free(&canonical_headers);
curlx_dyn_free(&signed_headers);
- free(canonical_request);
- free(request_type);
- free(credential_scope);
- free(str_to_sign);
- free(secret);
- free(date_header);
+ curlx_free(canonical_request);
+ curlx_free(request_type);
+ curlx_free(credential_scope);
+ curlx_free(str_to_sign);
+ curlx_free(secret);
+ curlx_free(date_header);
return result;
}
#include "curlx/strparse.h"
#include "curlx/warnless.h"
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Chunk format (simplified):
*
#include "http_digest.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Test example headers:
WWW-Authenticate: Digest realm="testrealm", nonce="1053604598"
}
}
if(!tmp)
- path = (unsigned char *)strdup((const char *) uripath);
+ path = (unsigned char *)curlx_strdup((const char *) uripath);
if(!path)
return CURLE_OUT_OF_MEMORY;
result = Curl_auth_create_digest_http_message(data, userp, passwdp, request,
path, digest, &response, &len);
- free(path);
+ curlx_free(path);
if(result)
return result;
*allocuserpwd = curl_maprintf("%sAuthorization: Digest %s\r\n",
proxy ? "Proxy-" : "", response);
- free(response);
+ curlx_free(response);
if(!*allocuserpwd)
return CURLE_OUT_OF_MEMORY;
#include "vtls/vtls.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void http_auth_nego_reset(struct connectdata *conn,
struct negotiatedata *neg_ctx,
if(proxy) {
#ifndef CURL_DISABLE_PROXY
- free(data->state.aptr.proxyuserpwd);
+ curlx_free(data->state.aptr.proxyuserpwd);
data->state.aptr.proxyuserpwd = userp;
#endif
}
else {
- free(data->state.aptr.userpwd);
+ curlx_free(data->state.aptr.userpwd);
data->state.aptr.userpwd = userp;
}
- free(base64);
+ curlx_free(base64);
if(!userp) {
return CURLE_OUT_OF_MEMORY;
#include "curl_sspi.h"
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
CURLcode Curl_input_ntlm(struct Curl_easy *data,
bool proxy, /* if proxy or not */
const char *header) /* rest of the www-authenticate:
result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
Curl_bufref_len(&ntlmmsg), &base64, &len);
if(!result) {
- free(*allocuserpwd);
+ curlx_free(*allocuserpwd);
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
base64);
- free(base64);
+ curlx_free(base64);
if(!*allocuserpwd)
result = CURLE_OUT_OF_MEMORY;
}
result = curlx_base64_encode(Curl_bufref_ptr(&ntlmmsg),
Curl_bufref_len(&ntlmmsg), &base64, &len);
if(!result) {
- free(*allocuserpwd);
+ curlx_free(*allocuserpwd);
*allocuserpwd = curl_maprintf("%sAuthorization: NTLM %s\r\n",
proxy ? "Proxy-" : "",
base64);
- free(base64);
+ curlx_free(base64);
if(!*allocuserpwd)
result = CURLE_OUT_OF_MEMORY;
else {
#include "vauth/vauth.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static CURLcode dynhds_add_custom(struct Curl_easy *data,
bool is_connect, int httpversion,
struct dynhds *hds)
Curl_http_req_free(req);
req = NULL;
}
- free(authority);
+ curlx_free(authority);
*preq = req;
return result;
}
(void)data;
CURL_TRC_CF(data, cf, "destroy");
- free(ctx);
+ curlx_free(ctx);
}
static void http_proxy_cf_close(struct Curl_cfilter *cf,
CURLcode result;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
Curl_conn_cf_insert_after(cf_at, cf);
out:
- free(ctx);
+ curlx_free(ctx);
return result;
}
#include "sendf.h"
#include "strdup.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static CURLcode httpsrr_decode_alpn(const uint8_t *cp, size_t len,
unsigned char *alpns)
{
case HTTPS_RR_CODE_IPV4: /* addr4 list */
if(!vlen || (vlen & 3)) /* the size must be 4-byte aligned */
return CURLE_BAD_FUNCTION_ARGUMENT;
- free(hi->ipv4hints);
+ curlx_free(hi->ipv4hints);
hi->ipv4hints = Curl_memdup(val, vlen);
if(!hi->ipv4hints)
return CURLE_OUT_OF_MEMORY;
case HTTPS_RR_CODE_ECH:
if(!vlen)
return CURLE_BAD_FUNCTION_ARGUMENT;
- free(hi->echconfiglist);
+ curlx_free(hi->echconfiglist);
hi->echconfiglist = Curl_memdup(val, vlen);
if(!hi->echconfiglist)
return CURLE_OUT_OF_MEMORY;
case HTTPS_RR_CODE_IPV6: /* addr6 list */
if(!vlen || (vlen & 15)) /* the size must be 16-byte aligned */
return CURLE_BAD_FUNCTION_ARGUMENT;
- free(hi->ipv6hints);
+ curlx_free(hi->ipv6hints);
hi->ipv6hints = Curl_memdup(val, vlen);
if(!hi->ipv6hints)
return CURLE_OUT_OF_MEMORY;
is in ServiceMode */
target = ares_dns_rr_get_str(rr, ARES_RR_HTTPS_TARGET);
if(target && target[0]) {
- free(hinfo->target);
- hinfo->target = strdup(target);
+ curlx_free(hinfo->target);
+ hinfo->target = curlx_strdup(target);
if(!hinfo->target) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#endif
#endif /* USE_LIBIDN2 */
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* for macOS and iOS targets */
#ifdef USE_APPLE_IDN
#include <unicode/uidna.h>
buffer, sizeof(buffer) - 1, &info, &err);
uidna_close(idna);
if(!U_FAILURE(err) && !info.errors) {
- *out = strdup(buffer);
+ *out = curlx_strdup(buffer);
if(*out)
return CURLE_OK;
else
sizeof(buffer) - 1, &info, &err);
uidna_close(idna);
if(!U_FAILURE(err)) {
- *out = strdup(buffer);
+ *out = curlx_strdup(buffer);
if(*out)
return CURLE_OK;
else
if(chars) {
char *mstr = curlx_convert_wchar_to_UTF8(punycode);
if(mstr) {
- *out = strdup(mstr);
+ *out = curlx_strdup(mstr);
curlx_unicodefree(mstr);
if(!*out)
return CURLE_OUT_OF_MEMORY;
/* 'chars' is "the number of characters retrieved" */
char *mstr = curlx_convert_wchar_to_UTF8(idn);
if(mstr) {
- out = strdup(mstr);
+ out = curlx_strdup(mstr);
curlx_unicodefree(mstr);
if(!out)
return CURLE_OUT_OF_MEMORY;
CURLcode result = idn_decode(input, &d);
#ifdef USE_LIBIDN2
if(!result) {
- char *c = strdup(d);
+ char *c = curlx_strdup(d);
idn2_free(d);
if(c)
d = c;
if(!result) {
if(!d[0]) { /* ended up zero length, not acceptable */
result = CURLE_URL_MALFORMAT;
- free(d);
+ curlx_free(d);
}
else
*output = d;
CURLcode result = idn_encode(puny, &d);
#ifdef USE_LIBIDN2
if(!result) {
- char *c = strdup(d);
+ char *c = curlx_strdup(d);
idn2_free(d);
if(c)
d = c;
#include "curlx/inet_ntop.h"
#include "if2ip.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* ------------------------------------------------------------------ */
#ifdef USE_IPV6
#include "curlx/warnless.h"
#include "curl_ctype.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* meta key for storing protocol meta at easy handle */
#define CURL_META_IMAP_EASY "meta:proto:imap:easy"
result = imap_sendf(data, imapc, "LOGIN %s %s", user ? user : "",
passwd ? passwd : "");
- free(user);
- free(passwd);
+ curlx_free(user);
+ curlx_free(passwd);
if(!result)
imap_state(data, imapc, IMAP_LOGIN);
else {
/* Make sure the mailbox is in the correct atom format if necessary */
char *mailbox = imap->mailbox ? imap_atom(imap->mailbox, TRUE)
- : strdup("");
+ : curlx_strdup("");
if(!mailbox)
return CURLE_OUT_OF_MEMORY;
/* Send the LIST command */
result = imap_sendf(data, imapc, "LIST \"%s\" *", mailbox);
- free(mailbox);
+ curlx_free(mailbox);
}
if(!result)
/* Send the SELECT command */
result = imap_sendf(data, imapc, "SELECT %s", mailbox);
- free(mailbox);
+ curlx_free(mailbox);
if(!result)
imap_state(data, imapc, IMAP_SELECT);
cleanup:
curlx_dyn_free(&flags);
- free(mailbox);
+ curlx_free(mailbox);
if(!result)
imap_state(data, imapc, IMAP_APPEND);
else {
/* Note the currently opened mailbox on this connection */
DEBUGASSERT(!imapc->mailbox);
- imapc->mailbox = strdup(imap->mailbox);
+ imapc->mailbox = curlx_strdup(imap->mailbox);
if(!imapc->mailbox)
return CURLE_OUT_OF_MEMORY;
(void)key;
(void)klen;
imap_easy_reset(imap);
- free(imap);
+ curlx_free(imap);
}
static void imap_conn_dtor(void *key, size_t klen, void *entry)
Curl_pp_disconnect(&imapc->pp);
curlx_dyn_free(&imapc->dyn);
Curl_safefree(imapc->mailbox);
- free(imapc);
+ curlx_free(imapc);
}
static CURLcode imap_setup_connection(struct Curl_easy *data,
struct pingpong *pp;
struct IMAP *imap;
- imapc = calloc(1, sizeof(*imapc));
+ imapc = curlx_calloc(1, sizeof(*imapc));
if(!imapc)
return CURLE_OUT_OF_MEMORY;
if(Curl_conn_meta_set(conn, CURL_META_IMAP_CONN, imapc, imap_conn_dtor))
return CURLE_OUT_OF_MEMORY;
- imap = calloc(1, sizeof(struct IMAP));
+ imap = curlx_calloc(1, sizeof(struct IMAP));
if(!imap ||
Curl_meta_set(data, CURL_META_IMAP_EASY, imap, imap_easy_dtor))
return CURLE_OUT_OF_MEMORY;
nclean = strcspn(str, "() {%*]\\\"");
if(len == nclean)
/* nothing to escape, return a strdup */
- return strdup(str);
+ return curlx_strdup(str);
curlx_dyn_init(&line, 2000);
result = Curl_urldecode(begin, ptr - begin, &value, &valuelen,
REJECT_CTRL);
if(result) {
- free(name);
+ curlx_free(name);
return result;
}
imap->uidvalidity = (unsigned int)num;
imap->uidvalidity_set = TRUE;
}
- free(value);
+ curlx_free(value);
}
else if(curl_strequal(name, "UID") && !imap->uid) {
imap->uid = value;
imap->partial = value;
}
else {
- free(name);
- free(value);
+ curlx_free(name);
+ curlx_free(value);
return CURLE_URL_MALFORMAT;
}
}
else
/* blank? */
- free(value);
- free(name);
+ curlx_free(value);
+ curlx_free(name);
}
/* Does the URL contain a query parameter? Only valid when we have a mailbox
params++;
if(*params) {
- imap->custom_params = strdup(params);
+ imap->custom_params = curlx_strdup(params);
imap->custom[params - imap->custom] = '\0';
if(!imap->custom_params)
#include "curlx/base64.h"
#include "connect.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef USE_WIN32_LDAP
#define FREE_ON_WINLDAP(x) curlx_unicodefree(x)
#define curl_ldap_num_t ULONG
if(val_b64_sz > 0) {
result = Curl_client_write(data, CLIENTWRITE_BODY, val_b64,
val_b64_sz);
- free(val_b64);
+ curlx_free(val_b64);
if(result) {
ldap_value_free_len(vals);
FREE_ON_WINLDAP(attr);
ludp->lud_host = conn->host.name;
/* Duplicate the path */
- p = path = strdup(data->state.up.path + 1);
+ p = path = curlx_strdup(data->state.up.path + 1);
if(!path)
return LDAP_NO_MEMORY;
/* Duplicate the query if present */
if(data->state.up.query) {
- q = query = strdup(data->state.up.query);
+ q = query = curlx_strdup(data->state.up.query);
if(!query) {
- free(path);
+ curlx_free(path);
return LDAP_NO_MEMORY;
}
}
ludp->lud_dn = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- free(unescaped);
+ curlx_free(unescaped);
if(!ludp->lud_dn) {
rc = LDAP_NO_MEMORY;
/* Allocate our array (+1 for the NULL entry) */
#ifdef USE_WIN32_LDAP
- ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
+ ludp->lud_attrs = curlx_calloc(count + 1, sizeof(TCHAR *));
#else
- ludp->lud_attrs = calloc(count + 1, sizeof(char *));
+ ludp->lud_attrs = curlx_calloc(count + 1, sizeof(char *));
#endif
if(!ludp->lud_attrs) {
rc = LDAP_NO_MEMORY;
ludp->lud_attrs[i] = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- free(unescaped);
+ curlx_free(unescaped);
if(!ludp->lud_attrs[i]) {
rc = LDAP_NO_MEMORY;
ludp->lud_filter = curlx_convert_UTF8_to_tchar(unescaped);
/* Free the unescaped string as we are done with it */
- free(unescaped);
+ curlx_free(unescaped);
if(!ludp->lud_filter) {
rc = LDAP_NO_MEMORY;
}
quit:
- free(path);
- free(query);
+ curlx_free(path);
+ curlx_free(query);
return rc;
}
const struct connectdata *conn,
LDAPURLDesc **ludpp)
{
- LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
+ LDAPURLDesc *ludp = curlx_calloc(1, sizeof(*ludp));
curl_ldap_num_t rc;
*ludpp = NULL;
curlx_unicodefree(ludp->lud_dn);
curlx_unicodefree(ludp->lud_filter);
#else
- free(ludp->lud_dn);
- free(ludp->lud_filter);
+ curlx_free(ludp->lud_dn);
+ curlx_free(ludp->lud_filter);
#endif
if(ludp->lud_attrs) {
#ifdef USE_WIN32_LDAP
curlx_unicodefree(ludp->lud_attrs[i]);
#else
- free(ludp->lud_attrs[i]);
+ curlx_free(ludp->lud_attrs[i]);
#endif
}
- free(ludp->lud_attrs);
+ curlx_free(ludp->lud_attrs);
}
- free(ludp);
+ curlx_free(ludp);
}
#endif /* !HAVE_LDAP_URL_PARSE */
#include <curl/curl.h>
#include "llist.h"
-#include "curl_memory.h"
-
-/* this must be the last include file */
-#include "memdebug.h"
#ifdef DEBUGBUILD
#define LLISTINIT 0x100cc001 /* random pattern */
#include <nettle/md4.h>
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4)
#include <wincrypt.h>
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef USE_GNUTLS
typedef struct md5_ctx my_md5_ctx;
struct MD5_context *ctxt;
/* Create MD5 context */
- ctxt = malloc(sizeof(*ctxt));
+ ctxt = curlx_malloc(sizeof(*ctxt));
if(!ctxt)
return ctxt;
- ctxt->md5_hashctx = malloc(md5params->md5_ctxtsize);
+ ctxt->md5_hashctx = curlx_malloc(md5params->md5_ctxtsize);
if(!ctxt->md5_hashctx) {
- free(ctxt);
+ curlx_free(ctxt);
return NULL;
}
ctxt->md5_hash = md5params;
if((*md5params->md5_init_func)(ctxt->md5_hashctx)) {
- free(ctxt->md5_hashctx);
- free(ctxt);
+ curlx_free(ctxt->md5_hashctx);
+ curlx_free(ctxt);
return NULL;
}
{
(*context->md5_hash->md5_final_func)(result, context->md5_hashctx);
- free(context->md5_hashctx);
- free(context);
+ curlx_free(context->md5_hashctx);
+ curlx_free(context);
return CURLE_OK;
}
#include "backtrace.h"
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
struct memdebug {
size_t size;
union {
+++ /dev/null
-#ifndef HEADER_CURL_MEMDEBUG_H
-#define HEADER_CURL_MEMDEBUG_H
-/***************************************************************************
- * _ _ ____ _
- * Project ___| | | | _ \| |
- * / __| | | | |_) | |
- * | (__| |_| | _ <| |___
- * \___|\___/|_| \_\_____|
- *
- * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
- *
- * You may opt to use, copy, modify, merge, publish, distribute and/or sell
- * copies of the Software, and permit persons to whom the Software is
- * furnished to do so, under the terms of the COPYING file.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- * SPDX-License-Identifier: curl
- *
- ***************************************************************************/
-
-/*
- * CAUTION: this header is designed to work when included by the app-side
- * as well as the library. Do not mix with library internals!
- */
-
-#ifdef CURLDEBUG
-
-/* Set this symbol on the command-line, recompile all lib-sources */
-#undef strdup
-#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
-#undef malloc
-#define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
-#undef calloc
-#define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
-#undef realloc
-#define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
-#undef free
-#define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
-
-#ifdef _WIN32
-#undef Curl_tcsdup
-#ifdef UNICODE
-#define Curl_tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
-#else
-#define Curl_tcsdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
-#endif
-#endif /* _WIN32 */
-
-#endif /* CURLDEBUG */
-#endif /* HEADER_CURL_MEMDEBUG_H */
#include "slist.h"
#include "curlx/dynbuf.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef _WIN32
# ifndef R_OK
# define R_OK 4
{
char *filename;
char *base;
- filename = strdup(fullfile); /* duplicate since basename() may ruin the
- buffer it works on */
+ filename = curlx_strdup(fullfile); /* duplicate since basename() may ruin
+ the buffer it works on */
if(!filename)
return NULL;
- base = strdup(basename(filename));
+ base = curlx_strdup(basename(filename));
- free(filename); /* free temporary buffer */
+ curlx_free(filename); /* free temporary buffer */
return base; /* returns an allocated string or NULL ! */
}
part = mime->firstpart;
mime->firstpart = part->nextpart;
Curl_mime_cleanpart(part);
- free(part);
+ curlx_free(part);
}
- free(mime);
+ curlx_free(mime);
}
}
{
curl_mime *mime;
- mime = (curl_mime *) malloc(sizeof(*mime));
+ mime = (curl_mime *)curlx_malloc(sizeof(*mime));
if(mime) {
mime->parent = NULL;
(unsigned char *) &mime->boundary[MIME_BOUNDARY_DASHES],
MIME_RAND_BOUNDARY_CHARS + 1)) {
/* failed to get random separator, bail out */
- free(mime);
+ curlx_free(mime);
return NULL;
}
mimesetstate(&mime->state, MIMESTATE_BEGIN, NULL);
if(!mime)
return NULL;
- part = (curl_mimepart *) malloc(sizeof(*part));
+ part = (curl_mimepart *)curlx_malloc(sizeof(*part));
if(part) {
Curl_mime_initpart(part);
Curl_safefree(part->name);
if(name) {
- part->name = strdup(name);
+ part->name = curlx_strdup(name);
if(!part->name)
return CURLE_OUT_OF_MEMORY;
}
Curl_safefree(part->filename);
if(filename) {
- part->filename = strdup(filename);
+ part->filename = curlx_strdup(filename);
if(!part->filename)
return CURLE_OUT_OF_MEMORY;
}
if(curlx_stat(filename, &sbuf))
result = CURLE_READ_ERROR;
else {
- part->data = strdup(filename);
+ part->data = curlx_strdup(filename);
if(!part->data)
result = CURLE_OUT_OF_MEMORY;
else {
result = CURLE_OUT_OF_MEMORY;
else {
result = curl_mime_filename(part, base);
- free(base);
+ curlx_free(base);
}
}
}
Curl_safefree(part->mimetype);
if(mimetype) {
- part->mimetype = strdup(mimetype);
+ part->mimetype = curlx_strdup(mimetype);
if(!part->mimetype)
return CURLE_OUT_OF_MEMORY;
}
if(hdr)
*slp = hdr;
else
- free(s);
+ curlx_free(s);
}
return hdr ? CURLE_OK : CURLE_OUT_OF_MEMORY;
#include "curl_printf.h"
#include "curlx/strparse.h"
-#include "curl_memory.h"
-/* The last #include file should be: */
-#include "memdebug.h"
-
#ifdef HAVE_LONGLONG
# define LONG_LONG_TYPE long long
# define HAVE_LONG_LONG_TYPE
}
if(curlx_dyn_len(info.b))
return curlx_dyn_ptr(info.b);
- return strdup("");
+ return curlx_strdup("");
}
char *curl_maprintf(const char *format, ...)
#include "multiif.h"
#include "rand.h"
-/* The last 2 #includes file should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* first byte is command.
second byte is for flags. */
#define MQTT_MSG_CONNECT 0x10
(void)klen;
curlx_dyn_free(&mq->sendbuf);
curlx_dyn_free(&mq->recvbuf);
- free(mq);
+ curlx_free(mq);
}
static void mqtt_conn_dtor(void *key, size_t klen, void *entry)
{
(void)key;
(void)klen;
- free(entry);
+ curlx_free(entry);
}
static CURLcode mqtt_setup_conn(struct Curl_easy *data,
struct mqtt_conn *mqtt;
struct MQTT *mq;
- mqtt = calloc(1, sizeof(*mqtt));
+ mqtt = curlx_calloc(1, sizeof(*mqtt));
if(!mqtt ||
Curl_conn_meta_set(conn, CURL_META_MQTT_CONN, mqtt, mqtt_conn_dtor))
return CURLE_OUT_OF_MEMORY;
- mq = calloc(1, sizeof(struct MQTT));
+ mq = curlx_calloc(1, sizeof(struct MQTT));
if(!mq)
return CURLE_OUT_OF_MEMORY;
curlx_dyn_init(&mq->recvbuf, DYN_MQTT_RECV);
/* allocating packet */
if(packetlen > 0xFFFFFFF)
return CURLE_WEIRD_SERVER_REPLY;
- packet = calloc(1, packetlen);
+ packet = curlx_calloc(1, packetlen);
if(!packet)
return CURLE_OUT_OF_MEMORY;
end:
if(packet)
- free(packet);
+ curlx_free(packet);
Curl_safefree(data->state.aptr.user);
Curl_safefree(data->state.aptr.passwd);
return result;
n = mqtt_encode_len((char *)encodedsize, packetlen);
packetlen += n + 1; /* add one for the control packet type byte */
- packet = malloc(packetlen);
+ packet = curlx_malloc(packetlen);
if(!packet) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
result = mqtt_send(data, (const char *)packet, packetlen);
fail:
- free(topic);
- free(packet);
+ curlx_free(topic);
+ curlx_free(packet);
return result;
}
}
/* add the control byte and the encoded remaining length */
- pkt = malloc(remaininglength + 1 + encodelen);
+ pkt = curlx_malloc(remaininglength + 1 + encodelen);
if(!pkt) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
result = mqtt_send(data, (const char *)pkt, i);
fail:
- free(pkt);
- free(topic);
+ curlx_free(pkt);
+ curlx_free(topic);
return result;
}
#include "socks.h"
#include "urlapi-int.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* initial multi->xfers table size for a full multi */
#define CURL_XFER_TABLE_SIZE 512
size_t dnssize, /* dns hash */
size_t sesssize) /* TLS session cache */
{
- struct Curl_multi *multi = calloc(1, sizeof(struct Curl_multi));
+ struct Curl_multi *multi = curlx_calloc(1, sizeof(struct Curl_multi));
if(!multi)
return NULL;
Curl_uint32_bset_destroy(&multi->msgsent);
Curl_uint32_tbl_destroy(&multi->xfers);
- free(multi);
+ curlx_free(multi);
return NULL;
}
data->state.errorbuf = FALSE;
if(!newurl)
/* typically for HTTP_1_1_REQUIRED error on first flight */
- newurl = strdup(data->state.url);
+ newurl = curlx_strdup(data->state.url);
if(!newurl) {
result = CURLE_OUT_OF_MEMORY;
}
if(!retry) {
/* if the URL is a follow-location and not just a retried request then
figure out the URL here */
- free(newurl);
+ curlx_free(newurl);
newurl = data->req.newurl;
data->req.newurl = NULL;
follow = FOLLOW_REDIR;
/* but first check to see if we got a location info even though we are
not following redirects */
if(data->req.location) {
- free(newurl);
+ curlx_free(newurl);
newurl = data->req.location;
data->req.location = NULL;
result = multi_follow(data, handler, newurl, FOLLOW_FAKE);
*nowp = curlx_now();
mspeed_check(data, *nowp);
}
- free(newurl);
+ curlx_free(newurl);
*resultp = result;
return rc;
}
/* Have error handler disconnect conn if we cannot retry */
*stream_errorp = TRUE;
}
- free(newurl);
+ curlx_free(newurl);
}
else {
/* failure detected */
Curl_uint32_bset_destroy(&multi->pending);
Curl_uint32_bset_destroy(&multi->msgsent);
Curl_uint32_tbl_destroy(&multi->xfers);
- free(multi);
+ curlx_free(multi);
return CURLM_OK;
}
struct Curl_multi *multi = m;
void *entry;
unsigned int count = Curl_uint32_tbl_count(&multi->xfers);
- CURL **a = malloc(sizeof(struct Curl_easy *) * (count + 1));
+ CURL **a = curlx_malloc(sizeof(struct Curl_easy *) * (count + 1));
if(a) {
unsigned int i = 0, mid;
if(data->multi->xfer_buf &&
data->set.buffer_size > data->multi->xfer_buf_len) {
/* not large enough, get a new one */
- free(data->multi->xfer_buf);
+ curlx_free(data->multi->xfer_buf);
data->multi->xfer_buf = NULL;
data->multi->xfer_buf_len = 0;
}
if(!data->multi->xfer_buf) {
- data->multi->xfer_buf = malloc(curlx_uitouz(data->set.buffer_size));
+ data->multi->xfer_buf = curlx_malloc(curlx_uitouz(data->set.buffer_size));
if(!data->multi->xfer_buf) {
failf(data, "could not allocate xfer_buf of %u bytes",
data->set.buffer_size);
if(data->multi->xfer_ulbuf &&
data->set.upload_buffer_size > data->multi->xfer_ulbuf_len) {
/* not large enough, get a new one */
- free(data->multi->xfer_ulbuf);
+ curlx_free(data->multi->xfer_ulbuf);
data->multi->xfer_ulbuf = NULL;
data->multi->xfer_ulbuf_len = 0;
}
if(!data->multi->xfer_ulbuf) {
data->multi->xfer_ulbuf =
- malloc(curlx_uitouz(data->set.upload_buffer_size));
+ curlx_malloc(curlx_uitouz(data->set.upload_buffer_size));
if(!data->multi->xfer_ulbuf) {
failf(data, "could not allocate xfer_ulbuf of %u bytes",
data->set.upload_buffer_size);
if(data->multi->xfer_sockbuf && blen > data->multi->xfer_sockbuf_len) {
/* not large enough, get a new one */
- free(data->multi->xfer_sockbuf);
+ curlx_free(data->multi->xfer_sockbuf);
data->multi->xfer_sockbuf = NULL;
data->multi->xfer_sockbuf_len = 0;
}
if(!data->multi->xfer_sockbuf) {
- data->multi->xfer_sockbuf = malloc(blen);
+ data->multi->xfer_sockbuf = curlx_malloc(blen);
if(!data->multi->xfer_sockbuf) {
failf(data, "could not allocate xfer_sockbuf of %zu bytes", blen);
return CURLE_OUT_OF_MEMORY;
#include "multihandle.h"
#include "socks.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static void mev_in_callback(struct Curl_multi *multi, bool value)
{
{
struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
Curl_uint32_spbset_destroy(&entry->xfers);
- free(entry);
+ curlx_free(entry);
}
/* look up a given socket in the socket hash, skip invalid sockets */
}
/* not present, add it */
- check = calloc(1, sizeof(struct mev_sh_entry));
+ check = curlx_calloc(1, sizeof(struct mev_sh_entry));
if(!check)
return NULL; /* major failure */
(void)klen;
if(ps) {
Curl_pollset_cleanup(ps);
- free(ps);
+ curlx_free(ps);
}
}
#include "multiif.h"
#include "multi_ntfy.h"
-/* The last 3 #include files should be in this order */
-#include "curl_printf.h"
-#include "curl_memory.h"
-#include "memdebug.h"
-
struct mntfy_entry {
uint32_t mid;
static struct mntfy_chunk *mnfty_chunk_create(void)
{
- return calloc(1, sizeof(struct mntfy_chunk));
+ return curlx_calloc(1, sizeof(struct mntfy_chunk));
}
static void mnfty_chunk_destroy(struct mntfy_chunk *chunk)
{
- free(chunk);
+ curlx_free(chunk);
}
static void mnfty_chunk_reset(struct mntfy_chunk *chunk)
#include "curlx/fopen.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Get user and password from .netrc when given a machine name */
enum host_lookup_state {
our_login = !Curl_timestrcmp(login, tok);
else {
our_login = TRUE;
- free(login);
- login = strdup(tok);
+ curlx_free(login);
+ login = curlx_strdup(tok);
if(!login) {
retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */
goto out;
keyword = NONE;
}
else if(keyword == PASSWORD) {
- free(password);
- password = strdup(tok);
+ curlx_free(password);
+ password = curlx_strdup(tok);
if(!password) {
retcode = NETRC_OUT_OF_MEMORY; /* allocation failed */
goto out;
if(!retcode) {
if(!password && our_login) {
/* success without a password, set a blank one */
- password = strdup("");
+ password = curlx_strdup("");
if(!password)
retcode = NETRC_OUT_OF_MEMORY; /* out of memory */
}
curlx_dyn_free(filebuf);
store->loaded = FALSE;
if(!specific_login)
- free(login);
- free(password);
+ curlx_free(login);
+ curlx_free(password);
}
return retcode;
filealloc = curl_maprintf("%s%s.netrc", home, DIR_CHAR);
if(!filealloc) {
- free(homea);
+ curlx_free(homea);
return NETRC_OUT_OF_MEMORY;
}
}
retcode = parsenetrc(store, host, loginp, passwordp, filealloc);
- free(filealloc);
+ curlx_free(filealloc);
#ifdef _WIN32
if(retcode == NETRC_FILE_MISSING) {
/* fallback to the old-style "_netrc" file */
filealloc = curl_maprintf("%s%s_netrc", home, DIR_CHAR);
if(!filealloc) {
- free(homea);
+ curlx_free(homea);
return NETRC_OUT_OF_MEMORY;
}
retcode = parsenetrc(store, host, loginp, passwordp, filealloc);
- free(filealloc);
+ curlx_free(filealloc);
}
#endif
- free(homea);
+ curlx_free(homea);
}
else
retcode = parsenetrc(store, host, loginp, passwordp, netrcfile);
#include "curl_sasl.h"
#include "strcase.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Uncommenting this will enable the built-in debug logging of the openldap
* library. The debug log level can be set using the CURL_OPENLDAP_TRACE
struct ldapreqinfo *lr = entry;
(void)key;
(void)klen;
- free(lr);
+ curlx_free(lr);
}
static void oldap_conn_dtor(void *key, size_t klen, void *entry)
ldap_unbind_ext(li->ld, NULL, NULL);
li->ld = NULL;
}
- free(li);
+ curlx_free(li);
}
static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
(void)done;
- li = calloc(1, sizeof(struct ldapconninfo));
+ li = curlx_calloc(1, sizeof(struct ldapconninfo));
if(!li) {
result = CURLE_OUT_OF_MEMORY;
goto out;
result = oldap_perform_bind(data, OLDAP_BIND);
out:
- free(hosturl);
+ curlx_free(hosturl);
return result;
}
goto out;
}
- lr = calloc(1, sizeof(struct ldapreqinfo));
+ lr = curlx_calloc(1, sizeof(struct ldapreqinfo));
if(!lr ||
Curl_meta_set(data, CURL_META_LDAP_EASY, lr, oldap_easy_dtor)) {
ldap_abandon_ext(li->ld, msgid, NULL, NULL);
if(!result)
result = client_write(data, STRCONST(": "), val_b64, val_b64_sz,
STRCONST("\n"));
- free(val_b64);
+ curlx_free(val_b64);
}
else
result = client_write(data, STRCONST(" "),
#include "multiif.h"
#include "vtls/vtls.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef USE_PINGPONG
/* Returns timeout in ms. 0 or negative number means the timeout has already
#include "curlx/warnless.h"
#include "strdup.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Authentication type flags */
#define POP3_TYPE_CLEARTEXT (1 << 0)
#define POP3_TYPE_APOP (1 << 1)
/* Cleanup our per-request based variables */
Curl_safefree(pop3->id);
Curl_safefree(pop3->custom);
- free(pop3);
+ curlx_free(pop3);
}
static void pop3_conn_dtor(void *key, size_t klen, void *entry)
DEBUGASSERT(pop3c);
Curl_pp_disconnect(&pop3c->pp);
Curl_safefree(pop3c->apoptimestamp);
- free(pop3c);
+ curlx_free(pop3c);
}
static CURLcode pop3_setup_connection(struct Curl_easy *data,
struct connectdata *conn)
{
struct pop3_conn *pop3c;
- struct POP3 *pop3 = calloc(1, sizeof(*pop3));
+ struct POP3 *pop3 = curlx_calloc(1, sizeof(*pop3));
if(!pop3 ||
Curl_meta_set(data, CURL_META_POP3_EASY, pop3, pop3_easy_dtor))
return CURLE_OUT_OF_MEMORY;
- pop3c = calloc(1, sizeof(*pop3c));
+ pop3c = curlx_calloc(1, sizeof(*pop3c));
if(!pop3c ||
Curl_conn_meta_set(conn, CURL_META_POP3_CONN, pop3c, pop3_conn_dtor))
return CURLE_OUT_OF_MEMORY;
#include "psl.h"
#include "curl_share.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
void Curl_psl_destroy(struct PslCache *pslcache)
{
if(pslcache->psl) {
#include "rand.h"
#include "escape.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef _WIN32
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_VISTA && \
#include "curlx/multibyte.h"
#include "curlx/timeval.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* return 0 on success, 1 on error */
int Curl_rename(const char *oldpath, const char *newpath)
{
#include "url.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
void Curl_req_init(struct SingleRequest *req)
{
memset(req, 0, sizeof(*req));
#include "strdup.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* meta key for storing protocol meta at easy handle */
#define CURL_META_RTSP_EASY "meta:proto:rtsp:easy"
struct RTSP *rtsp = entry;
(void)key;
(void)klen;
- free(rtsp);
+ curlx_free(rtsp);
}
static void rtsp_conn_dtor(void *key, size_t klen, void *entry)
(void)key;
(void)klen;
curlx_dyn_free(&rtspc->buf);
- free(rtspc);
+ curlx_free(rtspc);
}
static CURLcode rtsp_setup_connection(struct Curl_easy *data,
struct rtsp_conn *rtspc;
struct RTSP *rtsp;
- rtspc = calloc(1, sizeof(*rtspc));
+ rtspc = curlx_calloc(1, sizeof(*rtspc));
if(!rtspc)
return CURLE_OUT_OF_MEMORY;
curlx_dyn_init(&rtspc->buf, MAX_RTP_BUFFERSIZE);
if(Curl_conn_meta_set(conn, CURL_META_RTSP_CONN, rtspc, rtsp_conn_dtor))
return CURLE_OUT_OF_MEMORY;
- rtsp = calloc(1, sizeof(struct RTSP));
+ rtsp = curlx_calloc(1, sizeof(struct RTSP));
if(!rtsp ||
Curl_meta_set(data, CURL_META_RTSP_EASY, rtsp, rtsp_easy_dtor))
return CURLE_OUT_OF_MEMORY;
to this origin */
if(!data->state.first_host) {
- data->state.first_host = strdup(conn->host.name);
+ data->state.first_host = curlx_strdup(conn->host.name);
if(!data->state.first_host)
return CURLE_OUT_OF_MEMORY;
if(rtspreq == RTSPREQ_SETUP && !p_transport) {
/* New Transport: setting? */
if(data->set.str[STRING_RTSP_TRANSPORT]) {
- free(data->state.aptr.rtsp_transport);
+ curlx_free(data->state.aptr.rtsp_transport);
data->state.aptr.rtsp_transport =
curl_maprintf("Transport: %s\r\n",
data->set.str[STRING_RTSP_TRANSPORT]);
/* Accept-Encoding header */
if(!Curl_checkheaders(data, STRCONST("Accept-Encoding")) &&
data->set.str[STRING_ENCODING]) {
- free(data->state.aptr.accept_encoding);
+ curlx_free(data->state.aptr.accept_encoding);
data->state.aptr.accept_encoding =
curl_maprintf("Accept-Encoding: %s\r\n",
data->set.str[STRING_ENCODING]);
/* Check to see if there is a range set in the custom headers */
if(!Curl_checkheaders(data, STRCONST("Range")) && data->state.range) {
- free(data->state.aptr.rangeline);
+ curlx_free(data->state.aptr.rangeline);
data->state.aptr.rangeline = curl_maprintf("Range: %s\r\n",
data->state.range);
p_range = data->state.aptr.rangeline;
#include "curlx/wait.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifndef HAVE_POLL
/*
* This is a wrapper around select() to aid in Windows compatibility. A
{
DEBUGASSERT(cpfds);
if(cpfds->allocated_pfds) {
- free(cpfds->pfds);
+ curlx_free(cpfds->pfds);
}
memset(cpfds, 0, sizeof(*cpfds));
}
struct pollfd *new_fds;
unsigned int new_count = cpfds->count + inc;
- new_fds = calloc(new_count, sizeof(struct pollfd));
+ new_fds = curlx_calloc(new_count, sizeof(struct pollfd));
if(!new_fds)
return CURLE_OUT_OF_MEMORY;
memcpy(new_fds, cpfds->pfds, cpfds->count * sizeof(struct pollfd));
if(cpfds->allocated_pfds)
- free(cpfds->pfds);
+ curlx_free(cpfds->pfds);
cpfds->pfds = new_fds;
cpfds->count = new_count;
cpfds->allocated_pfds = TRUE;
struct easy_pollset *Curl_pollset_create(void)
{
- struct easy_pollset *ps = calloc(1, sizeof(*ps));
+ struct easy_pollset *ps = curlx_calloc(1, sizeof(*ps));
if(ps)
Curl_pollset_init(ps);
return ps;
DEBUGASSERT(ps->init == CURL_EASY_POLLSET_MAGIC);
#endif
if(ps->sockets != ps->def_sockets) {
- free(ps->sockets);
+ curlx_free(ps->sockets);
ps->sockets = ps->def_sockets;
}
if(ps->actions != ps->def_actions) {
- free(ps->actions);
+ curlx_free(ps->actions);
ps->actions = ps->def_actions;
}
ps->count = CURL_ARRAYSIZE(ps->def_sockets);
ps->count, new_count);
if(new_count <= ps->count)
return CURLE_OUT_OF_MEMORY;
- nsockets = calloc(new_count, sizeof(nsockets[0]));
+ nsockets = curlx_calloc(new_count, sizeof(nsockets[0]));
if(!nsockets)
return CURLE_OUT_OF_MEMORY;
- nactions = calloc(new_count, sizeof(nactions[0]));
+ nactions = curlx_calloc(new_count, sizeof(nactions[0]));
if(!nactions) {
- free(nsockets);
+ curlx_free(nsockets);
return CURLE_OUT_OF_MEMORY;
}
memcpy(nsockets, ps->sockets, ps->count * sizeof(ps->sockets[0]));
memcpy(nactions, ps->actions, ps->count * sizeof(ps->actions[0]));
if(ps->sockets != ps->def_sockets)
- free(ps->sockets);
+ curlx_free(ps->sockets);
ps->sockets = nsockets;
if(ps->actions != ps->def_actions)
- free(ps->actions);
+ curlx_free(ps->actions);
ps->actions = nactions;
ps->count = new_count;
}
if(!ps->n)
return curlx_wait_ms(timeout_ms);
- pfds = calloc(ps->n, sizeof(*pfds));
+ pfds = curlx_calloc(ps->n, sizeof(*pfds));
if(!pfds)
return -1;
}
result = Curl_poll(pfds, npfds, timeout_ms);
- free(pfds);
+ curlx_free(pfds);
return result;
}
#include "curlx/warnless.h"
#include "ws.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static CURLcode do_init_writer_stack(struct Curl_easy *data);
while(writer) {
data->req.writer_stack = writer->next;
writer->cwt->do_close(data, writer);
- free(writer);
+ curlx_free(writer);
writer = data->req.writer_stack;
}
}
while(reader) {
data->req.reader_stack = reader->next;
reader->crt->do_close(data, reader);
- free(reader);
+ curlx_free(reader);
reader = data->req.reader_stack;
}
}
void *p;
DEBUGASSERT(cwt->cwriter_size >= sizeof(struct Curl_cwriter));
- p = calloc(1, cwt->cwriter_size);
+ p = curlx_calloc(1, cwt->cwriter_size);
if(!p)
goto out;
out:
*pwriter = result ? NULL : writer;
if(result)
- free(writer);
+ curlx_free(writer);
return result;
}
{
if(writer) {
writer->cwt->do_close(data, writer);
- free(writer);
+ curlx_free(writer);
}
}
void *p;
DEBUGASSERT(crt->creader_size >= sizeof(struct Curl_creader));
- p = calloc(1, crt->creader_size);
+ p = curlx_calloc(1, crt->creader_size);
if(!p)
goto out;
out:
*preader = result ? NULL : reader;
if(result)
- free(reader);
+ curlx_free(reader);
return result;
}
{
if(reader) {
reader->crt->do_close(data, reader);
- free(reader);
+ curlx_free(reader);
}
}
#include "strdup.h"
#include "escape.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
{
if(secs < 0)
if(strlen(s) > CURL_MAX_INPUT_LENGTH)
return CURLE_BAD_FUNCTION_ARGUMENT;
- *charp = strdup(s);
+ *charp = curlx_strdup(s);
if(!*charp)
return CURLE_OUT_OF_MEMORY;
}
if(blob->len > CURL_MAX_INPUT_LENGTH)
return CURLE_BAD_FUNCTION_ARGUMENT;
nblob = (struct curl_blob *)
- malloc(sizeof(struct curl_blob) +
- ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0));
+ curlx_malloc(sizeof(struct curl_blob) +
+ ((blob->flags & CURL_BLOB_COPY) ? blob->len : 0));
if(!nblob)
return CURLE_OUT_OF_MEMORY;
*nblob = *blob;
return result;
}
- free(*userp);
+ curlx_free(*userp);
*userp = user;
- free(*passwdp);
+ curlx_free(*passwdp);
*passwdp = passwd;
return CURLE_OK;
if(result)
return result;
}
- free(*devp);
+ curlx_free(*devp);
*devp = dev;
- free(*ifacep);
+ curlx_free(*ifacep);
*ifacep = iface;
- free(*hostp);
+ curlx_free(*hostp);
*hostp = host;
return CURLE_OK;
if(!p)
return CURLE_OUT_OF_MEMORY;
else {
- free(s->str[STRING_COPYPOSTFIELDS]);
+ curlx_free(s->str[STRING_COPYPOSTFIELDS]);
s->str[STRING_COPYPOSTFIELDS] = p;
}
}
result = Curl_urldecode(p, 0, &s->str[STRING_PROXYPASSWORD], NULL,
REJECT_ZERO);
}
- free(u);
- free(p);
+ curlx_free(u);
+ curlx_free(p);
}
break;
case CURLOPT_PROXYUSERNAME:
#include <wincrypt.h>
#endif
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* Please keep the SSL backend-specific #if branches in this order:
*
* 1. USE_OPENSSL
#include "slist.h"
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* returns last node in linked list */
static struct curl_slist *slist_get_last(struct curl_slist *list)
{
DEBUGASSERT(data);
- new_item = malloc(sizeof(struct curl_slist));
+ new_item = curlx_malloc(sizeof(struct curl_slist));
if(!new_item)
return NULL;
struct curl_slist *curl_slist_append(struct curl_slist *list,
const char *data)
{
- char *dupdata = strdup(data);
+ char *dupdata = curlx_strdup(data);
if(!dupdata)
return NULL;
list = Curl_slist_append_nodup(list, dupdata);
if(!list)
- free(dupdata);
+ curlx_free(dupdata);
return list;
}
do {
next = item->next;
Curl_safefree(item->data);
- free(item);
+ curlx_free(item);
item = next;
} while(next);
}
#include "escape.h"
#include "curl_endian.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* meta key for storing protocol meta at easy handle */
#define CURL_META_SMB_EASY "meta:proto:smb:easy"
/* `req->path` points to somewhere in `struct smb_conn` which is
* kept at the connection meta. If the connection is destroyed first,
* req->path points to free'd memory. */
- free(req);
+ curlx_free(req);
}
static void smb_conn_dtor(void *key, size_t klen, void *entry)
Curl_safefree(smbc->domain);
Curl_safefree(smbc->recv_buf);
Curl_safefree(smbc->send_buf);
- free(smbc);
+ curlx_free(smbc);
}
/* this should setup things in the connection, not in the easy
struct smb_request *req;
/* Initialize the connection state */
- smbc = calloc(1, sizeof(*smbc));
+ smbc = curlx_calloc(1, sizeof(*smbc));
if(!smbc ||
Curl_conn_meta_set(conn, CURL_META_SMB_CONN, smbc, smb_conn_dtor))
return CURLE_OUT_OF_MEMORY;
/* Initialize the request state */
- req = calloc(1, sizeof(*req));
+ req = curlx_calloc(1, sizeof(*req));
if(!req ||
Curl_meta_set(data, CURL_META_SMB_EASY, req, smb_easy_dtor))
return CURLE_OUT_OF_MEMORY;
/* Initialize the connection state */
smbc->state = SMB_CONNECTING;
- smbc->recv_buf = malloc(MAX_MESSAGE_SIZE);
+ smbc->recv_buf = curlx_malloc(MAX_MESSAGE_SIZE);
if(!smbc->recv_buf)
return CURLE_OUT_OF_MEMORY;
- smbc->send_buf = malloc(MAX_MESSAGE_SIZE);
+ smbc->send_buf = curlx_malloc(MAX_MESSAGE_SIZE);
if(!smbc->send_buf)
return CURLE_OUT_OF_MEMORY;
if(slash) {
smbc->user = slash + 1;
- smbc->domain = strdup(conn->user);
+ smbc->domain = curlx_strdup(conn->user);
if(!smbc->domain)
return CURLE_OUT_OF_MEMORY;
smbc->domain[slash - conn->user] = 0;
}
else {
smbc->user = conn->user;
- smbc->domain = strdup(conn->host.name);
+ smbc->domain = curlx_strdup(conn->host.name);
if(!smbc->domain)
return CURLE_OUT_OF_MEMORY;
}
return result;
/* Parse the path for the share */
- smbc->share = strdup((*path == '/' || *path == '\\') ? path + 1 : path);
- free(path);
+ smbc->share = curlx_strdup((*path == '/' || *path == '\\')
+ ? path + 1 : path);
+ curlx_free(path);
if(!smbc->share)
return CURLE_OUT_OF_MEMORY;
#include "idn.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* meta key for storing protocol meta at easy handle */
#define CURL_META_SMTP_EASY "meta:proto:smtp:easy"
/* meta key for storing protocol meta at connection */
utf8 ? " SMTPUTF8" : "");
Curl_free_idnconverted_hostname(&host);
- free(address);
+ curlx_free(address);
}
else {
/* Establish whether we should report that we support SMTPUTF8 for EXPN
worry about that and reply with a 501 error */
from = curl_maprintf("<%s>%s", address, suffix);
- free(address);
+ curlx_free(address);
}
else
/* Null reverse-path, RFC-5321, sect. 3.6.3 */
- from = strdup("<>");
+ from = curlx_strdup("<>");
if(!from) {
result = CURLE_OUT_OF_MEMORY;
/* An invalid mailbox was provided but we will simply let the server
worry about it */
auth = curl_maprintf("<%s>%s", address, suffix);
- free(address);
+ curlx_free(address);
}
else
/* Empty AUTH, RFC-2554, sect. 5 */
- auth = strdup("<>");
+ auth = curlx_strdup("<>");
if(!auth) {
result = CURLE_OUT_OF_MEMORY;
: ""); /* included in our envelope */
out:
- free(from);
- free(auth);
- free(size);
+ curlx_free(from);
+ curlx_free(auth);
+ curlx_free(size);
if(!result)
smtp_state(data, smtpc, SMTP_MAIL);
address, suffix);
Curl_free_idnconverted_hostname(&host);
- free(address);
+ curlx_free(address);
if(!result)
smtp_state(data, smtpc, SMTP_RCPT);
struct SMTP *smtp = entry;
(void)key;
(void)klen;
- free(smtp);
+ curlx_free(smtp);
}
static void smtp_conn_dtor(void *key, size_t klen, void *entry)
(void)klen;
Curl_pp_disconnect(&smtpc->pp);
Curl_safefree(smtpc->domain);
- free(smtpc);
+ curlx_free(smtpc);
}
static CURLcode smtp_setup_connection(struct Curl_easy *data,
struct SMTP *smtp;
CURLcode result = CURLE_OK;
- smtpc = calloc(1, sizeof(*smtpc));
+ smtpc = curlx_calloc(1, sizeof(*smtpc));
if(!smtpc ||
Curl_conn_meta_set(conn, CURL_META_SMTP_CONN, smtpc, smtp_conn_dtor)) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
- smtp = calloc(1, sizeof(*smtp));
+ smtp = curlx_calloc(1, sizeof(*smtp));
if(!smtp ||
Curl_meta_set(data, CURL_META_SMTP_EASY, smtp, smtp_easy_dtor))
result = CURLE_OUT_OF_MEMORY;
/* Duplicate the fully qualified email address so we can manipulate it,
ensuring it does not contain the delimiters if specified */
- char *dup = strdup(fqma[0] == '<' ? fqma + 1 : fqma);
+ char *dup = curlx_strdup(fqma[0] == '<' ? fqma + 1 : fqma);
if(!dup)
return CURLE_OUT_OF_MEMORY;
#include "curlx/timeval.h" /* needed before select.h */
#include "select.h" /* for Curl_poll */
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
int Curl_socketpair(int domain, int type, int protocol,
curl_socket_t socks[2], bool nonblocking)
{
#include "curlx/inet_pton.h"
#include "url.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
#define DEBUG_AND_VERBOSE
#endif
struct socks_state *sxstate = cf->ctx;
if(sxstate) {
Curl_bufq_free(&sxstate->iobuf);
- free(sxstate);
+ curlx_free(sxstate);
cf->ctx = NULL;
}
}
return result;
if(!sx) {
- cf->ctx = sx = calloc(1, sizeof(*sx));
+ cf->ctx = sx = curlx_calloc(1, sizeof(*sx));
if(!sx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "curlx/warnless.h"
#include "strdup.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if defined(__GNUC__) && defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
(gss_OID) GSS_C_NULL_OID, &server);
}
else {
- service.value = malloc(serviceptr_length +
- strlen(conn->socks_proxy.host.name) + 2);
+ service.value = curlx_malloc(serviceptr_length +
+ strlen(conn->socks_proxy.host.name) + 2);
if(!service.value)
return CURLE_OUT_OF_MEMORY;
service.length = serviceptr_length +
us_length = ntohs(us_length);
gss_recv_token.length = us_length;
- gss_recv_token.value = malloc(gss_recv_token.length);
+ gss_recv_token.value = curlx_malloc(gss_recv_token.length);
if(!gss_recv_token.value) {
failf(data,
"Could not allocate memory for GSS-API authentication "
us_length = ntohs(us_length);
gss_recv_token.length = us_length;
- gss_recv_token.value = malloc(gss_recv_token.length);
+ gss_recv_token.value = curlx_malloc(gss_recv_token.length);
if(!gss_recv_token.value) {
Curl_gss_delete_sec_context(&gss_status, &gss_context, NULL);
return CURLE_OUT_OF_MEMORY;
#include "curlx/multibyte.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/*
* Helper sspi error functions.
*/
/* prepare service name */
if(strchr(service, '/'))
- service_name = strdup(service);
+ service_name = curlx_strdup(service);
else
service_name = curl_maprintf("%s/%s",
service, conn->socks_proxy.host.name);
us_length = ntohs(us_length);
sspi_recv_token.cbBuffer = us_length;
- sspi_recv_token.pvBuffer = malloc(us_length);
+ sspi_recv_token.pvBuffer = curlx_malloc(us_length);
if(!sspi_recv_token.pvBuffer) {
result = CURLE_OUT_OF_MEMORY;
sspi_w_token[0].cbBuffer = sspi_sizes.cbSecurityTrailer;
sspi_w_token[0].BufferType = SECBUFFER_TOKEN;
- sspi_w_token[0].pvBuffer = malloc(sspi_sizes.cbSecurityTrailer);
+ sspi_w_token[0].pvBuffer = curlx_malloc(sspi_sizes.cbSecurityTrailer);
if(!sspi_w_token[0].pvBuffer) {
result = CURLE_OUT_OF_MEMORY;
}
sspi_w_token[1].cbBuffer = 1;
- sspi_w_token[1].pvBuffer = malloc(1);
+ sspi_w_token[1].pvBuffer = curlx_malloc(1);
if(!sspi_w_token[1].pvBuffer) {
result = CURLE_OUT_OF_MEMORY;
goto error;
memcpy(sspi_w_token[1].pvBuffer, &gss_enc, 1);
sspi_w_token[2].BufferType = SECBUFFER_PADDING;
sspi_w_token[2].cbBuffer = sspi_sizes.cbBlockSize;
- sspi_w_token[2].pvBuffer = malloc(sspi_sizes.cbBlockSize);
+ sspi_w_token[2].pvBuffer = curlx_malloc(sspi_sizes.cbBlockSize);
if(!sspi_w_token[2].pvBuffer) {
result = CURLE_OUT_OF_MEMORY;
goto error;
result = CURLE_COULDNT_CONNECT;
goto error;
}
- etbuf = malloc(etbuf_size);
+ etbuf = curlx_malloc(etbuf_size);
if(!etbuf) {
result = CURLE_OUT_OF_MEMORY;
goto error;
us_length = ntohs(us_length);
sspi_w_token[0].cbBuffer = us_length;
- sspi_w_token[0].pvBuffer = malloc(us_length);
+ sspi_w_token[0].pvBuffer = curlx_malloc(us_length);
if(!sspi_w_token[0].pvBuffer) {
result = CURLE_OUT_OF_MEMORY;
goto error;
/* since sspi_w_token[1].pvBuffer is allocated by the SSPI in this case, it
must be freed in this block using FreeContextBuffer() instead of
- potentially in error cleanup using free(). */
+ potentially in error cleanup using curlx_free(). */
if(check_sspi_err(data, status, "DecryptMessage")) {
failf(data, "Failed to query security context attributes.");
return CURLE_OK;
error:
(void)curlx_nonblock(sock, TRUE);
- free(service_name);
+ curlx_free(service_name);
Curl_pSecFn->DeleteSecurityContext(&sspi_context);
Curl_pSecFn->FreeCredentialsHandle(&cred_handle);
- free(sspi_recv_token.pvBuffer);
+ curlx_free(sspi_recv_token.pvBuffer);
if(sspi_send_token.pvBuffer)
Curl_pSecFn->FreeContextBuffer(sspi_send_token.pvBuffer);
if(names.sUserName)
Curl_pSecFn->FreeContextBuffer(names.sUserName);
- free(sspi_w_token[0].pvBuffer);
- free(sspi_w_token[1].pvBuffer);
- free(sspi_w_token[2].pvBuffer);
- free(etbuf);
+ curlx_free(sspi_w_token[0].pvBuffer);
+ curlx_free(sspi_w_token[1].pvBuffer);
+ curlx_free(sspi_w_token[2].pvBuffer);
+ curlx_free(etbuf);
return result;
}
#endif
#endif
#include "strdup.h"
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
#ifndef HAVE_STRDUP
char *Curl_strdup(const char *str)
len = strlen(str) + 1;
- newstr = malloc(len);
+ newstr = curlx_malloc(len);
if(!newstr)
return (char *)NULL;
***************************************************************************/
void *Curl_memdup(const void *src, size_t length)
{
- void *buffer = malloc(length);
+ void *buffer = curlx_malloc(length);
if(!buffer)
return NULL; /* fail */
***************************************************************************/
void *Curl_memdup0(const char *src, size_t length)
{
- char *buf = (length < SIZE_MAX) ? malloc(length + 1) : NULL;
+ char *buf = (length < SIZE_MAX) ? curlx_malloc(length + 1) : NULL;
if(!buf)
return NULL;
if(length) {
*
* Curl_saferealloc(ptr, size)
*
- * Does a normal realloc(), but will free the data pointer if the realloc
+ * Does a normal curlx_realloc(), but will free the data pointer if the realloc
* fails. If 'size' is non-zero, it will free the data and return a failure.
*
* This convenience function is provided and used to help us avoid a common
***************************************************************************/
void *Curl_saferealloc(void *ptr, size_t size)
{
- void *datap = realloc(ptr, size);
+ void *datap = curlx_realloc(ptr, size);
if(size && !datap)
/* only free 'ptr' if size was non-zero */
- free(ptr);
+ curlx_free(ptr);
return datap;
}
#include "curlx/winapi.h"
#include "strerror.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
const char *
curl_easy_strerror(CURLcode error)
{
#include "curl_sspi.h"
#include "curlx/warnless.h"
-/* The last #include files should be: */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifndef HAVE_IF_NAMETOINDEX
/* Handle of iphlpapp.dll */
static HMODULE s_hIpHlpApiDll = NULL;
/* Allocate space for the full DLL path (Room for the null-terminator
is included in systemdirlen) */
size_t filenamelen = _tcslen(filename);
- TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen));
+ TCHAR *path = curlx_malloc(sizeof(TCHAR) *
+ (systemdirlen + 1 + filenamelen));
if(path && GetSystemDirectory(path, systemdirlen)) {
/* Calculate the full DLL path */
_tcscpy(path + _tcslen(path), TEXT("\\"));
pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
LoadLibrary(path);
}
- free(path);
+ curlx_free(path);
}
}
return hModule;
#include "curlx/warnless.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#define SUBBUFSIZE 512
#define CURL_SB_CLEAR(x) x->subpointer = x->subbuffer
(void)klen;
curl_slist_free_all(tn->telnet_vars);
curlx_dyn_free(&tn->out);
- free(tn);
+ curlx_free(tn);
}
static
{
struct TELNET *tn;
- tn = calloc(1, sizeof(struct TELNET));
+ tn = curlx_calloc(1, sizeof(struct TELNET));
if(!tn)
return CURLE_OUT_OF_MEMORY;
#include "curlx/strerr.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/* RFC2348 allows the block size to be negotiated */
#define TFTP_BLKSIZE_DEFAULT 512
#define TFTP_OPTION_BLKSIZE "blksize"
if(strlen(filename) > (state->blksize - strlen(mode) - 4)) {
failf(data, "TFTP filename too long");
- free(filename);
+ curlx_free(filename);
return CURLE_TFTP_ILLEGAL; /* too long filename field */
}
state->blksize,
"%s%c%s%c", filename, '\0', mode, '\0');
sbytes = 4 + strlen(filename) + strlen(mode);
- free(filename);
+ curlx_free(filename);
/* optional addition of TFTP options */
if(!data->set.tftp_no_options) {
(void)klen;
Curl_safefree(state->rpacket.data);
Curl_safefree(state->spacket.data);
- free(state);
+ curlx_free(state);
}
/**********************************************************
blksize = TFTP_BLKSIZE_DEFAULT;
- state = calloc(1, sizeof(*state));
+ state = curlx_calloc(1, sizeof(*state));
if(!state ||
Curl_conn_meta_set(conn, CURL_META_TFTP_CONN, state, tftp_conn_dtor))
return CURLE_OUT_OF_MEMORY;
need_blksize = TFTP_BLKSIZE_DEFAULT;
if(!state->rpacket.data) {
- state->rpacket.data = calloc(1, need_blksize + 2 + 2);
+ state->rpacket.data = curlx_calloc(1, need_blksize + 2 + 2);
if(!state->rpacket.data)
return CURLE_OUT_OF_MEMORY;
}
if(!state->spacket.data) {
- state->spacket.data = calloc(1, need_blksize + 2 + 2);
+ state->spacket.data = curlx_calloc(1, need_blksize + 2 + 2);
if(!state->spacket.data)
return CURLE_OUT_OF_MEMORY;
#include "headers.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#if !defined(CURL_DISABLE_HTTP) || !defined(CURL_DISABLE_SMTP) || \
!defined(CURL_DISABLE_IMAP)
/*
is allowed to be changed by the user between transfers */
if(data->set.uh) {
CURLUcode uc;
- free(data->set.str[STRING_SET_URL]);
+ curlx_free(data->set.str[STRING_SET_URL]);
uc = curl_url_get(data->set.uh,
CURLUPART_URL, &data->set.str[STRING_SET_URL], 0);
if(uc) {
if(data->state.wildcardmatch) {
struct WildcardData *wc;
if(!data->wildcard) {
- data->wildcard = calloc(1, sizeof(struct WildcardData));
+ data->wildcard = curlx_calloc(1, sizeof(struct WildcardData));
if(!data->wildcard)
return CURLE_OUT_OF_MEMORY;
}
* protocol.
*/
if(!result && data->set.str[STRING_USERAGENT]) {
- free(data->state.aptr.uagent);
+ curlx_free(data->state.aptr.uagent);
data->state.aptr.uagent =
curl_maprintf("User-Agent: %s\r\n", data->set.str[STRING_USERAGENT]);
if(!data->state.aptr.uagent)
/* Returns CURLE_OK *and* sets '*url' if a request retry is wanted.
- NOTE: that the *url is malloc()ed. */
+ NOTE: that the *url is curlx_malloc()ed. */
CURLcode Curl_retry_request(struct Curl_easy *data, char **url)
{
struct connectdata *conn = data->conn;
}
infof(data, "Connection died, retrying a fresh connect (retry count: %d)",
data->state.retrycount);
- *url = strdup(data->state.url);
+ *url = curlx_strdup(data->state.url);
if(!*url)
return CURLE_OUT_OF_MEMORY;
#include "curl_setup.h"
#include "uint-bset.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef DEBUGBUILD
#define CURL_UINT32_BSET_MAGIC 0x62757473
#endif
DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
if(nslots != bset->nslots) {
- uint64_t *slots = calloc(nslots, sizeof(uint64_t));
+ uint64_t *slots = curlx_calloc(nslots, sizeof(uint64_t));
if(!slots)
return CURLE_OUT_OF_MEMORY;
if(bset->slots) {
memcpy(slots, bset->slots,
(CURLMIN(nslots, bset->nslots) * sizeof(uint64_t)));
- free(bset->slots);
+ curlx_free(bset->slots);
}
bset->slots = slots;
bset->nslots = nslots;
void Curl_uint32_bset_destroy(struct uint32_bset *bset)
{
DEBUGASSERT(bset->init == CURL_UINT32_BSET_MAGIC);
- free(bset->slots);
+ curlx_free(bset->slots);
memset(bset, 0, sizeof(*bset));
}
#include <curl/curl.h>
#include "uint-hash.h"
-#include "curl_memory.h"
-
-/* The last #include file should be: */
-#include "memdebug.h"
/* random patterns for API verification */
#ifdef DEBUGBUILD
struct uint_hash_entry *e;
/* allocate the struct for the hash entry */
- e = malloc(sizeof(*e));
+ e = curlx_malloc(sizeof(*e));
if(e) {
e->id = id;
e->next = NULL;
struct uint_hash_entry *e)
{
uint32_hash_entry_clear(h, e);
- free(e);
+ curlx_free(e);
}
static void uint32_hash_entry_unlink(struct uint_hash *h,
DEBUGASSERT(h->slots);
DEBUGASSERT(h->init == CURL_UINT32_HASHINIT);
if(!h->table) {
- h->table = calloc(h->slots, sizeof(*he));
+ h->table = curlx_calloc(h->slots, sizeof(*he));
if(!h->table)
return FALSE; /* OOM */
}
#include "uint-bset.h"
#include "uint-spbset.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef DEBUGBUILD
#define CURL_UINT32_SPBSET_MAGIC 0x70737362
#endif
for(chunk = bset->head.next; chunk; chunk = next) {
next = chunk->next;
- free(chunk);
+ curlx_free(chunk);
}
memset(&bset->head, 0, sizeof(bset->head));
}
return NULL;
/* need a new one */
- chunk = calloc(1, sizeof(*chunk));
+ chunk = curlx_calloc(1, sizeof(*chunk));
if(!chunk)
return NULL;
#include "curl_setup.h"
#include "uint-table.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef DEBUGBUILD
#define CURL_UINT32_TBL_MAGIC 0x62757473
#endif
if(!nrows)
return CURLE_BAD_FUNCTION_ARGUMENT;
if(nrows != tbl->nrows) {
- void **rows = calloc(nrows, sizeof(void *));
+ void **rows = curlx_calloc(nrows, sizeof(void *));
if(!rows)
return CURLE_OUT_OF_MEMORY;
if(tbl->rows) {
memcpy(rows, tbl->rows, (CURLMIN(nrows, tbl->nrows) * sizeof(void *)));
if(nrows < tbl->nrows)
uint32_tbl_clear_rows(tbl, nrows, tbl->nrows);
- free(tbl->rows);
+ curlx_free(tbl->rows);
}
tbl->rows = rows;
tbl->nrows = nrows;
{
DEBUGASSERT(tbl->init == CURL_UINT32_TBL_MAGIC);
Curl_uint32_tbl_clear(tbl);
- free(tbl->rows);
+ curlx_free(tbl->rows);
memset(tbl, 0, sizeof(*tbl));
}
#include "curlx/strerr.h"
#include "curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef USE_NGHTTP2
static void data_priority_cleanup(struct Curl_easy *data);
#else
Curl_expire_clear(data); /* shut off any timers left */
if(data->state.rangestringalloc)
- free(data->state.range);
+ curlx_free(data->state.range);
/* release any resolve information this transfer kept */
Curl_async_destroy(data);
Curl_freeset(data);
Curl_headers_cleanup(data);
Curl_netrc_cleanup(&data->state.netrc);
- free(data);
+ curlx_free(data);
return CURLE_OK;
}
struct Curl_easy *data;
/* simple start-up: alloc the struct, init it with zeroes and return */
- data = calloc(1, sizeof(struct Curl_easy));
+ data = curlx_calloc(1, sizeof(struct Curl_easy));
if(!data) {
/* this is a serious error */
DEBUGF(curl_mfprintf(stderr, "Error: calloc of Curl_easy failed\n"));
Curl_uint32_spbset_destroy(&conn->xfers_attached);
Curl_hash_destroy(&conn->meta_hash);
- free(conn); /* free all the connection oriented data */
+ curlx_free(conn); /* free all the connection oriented data */
}
/*
*/
static struct connectdata *allocate_conn(struct Curl_easy *data)
{
- struct connectdata *conn = calloc(1, sizeof(struct connectdata));
+ struct connectdata *conn = curlx_calloc(1, sizeof(struct connectdata));
if(!conn)
return NULL;
/* Store the local bind parameters that will be used for this connection */
if(data->set.str[STRING_DEVICE]) {
- conn->localdev = strdup(data->set.str[STRING_DEVICE]);
+ conn->localdev = curlx_strdup(data->set.str[STRING_DEVICE]);
if(!conn->localdev)
goto error;
}
return conn;
error:
- free(conn->localdev);
- free(conn);
+ curlx_free(conn->localdev);
+ curlx_free(conn);
return NULL;
}
}
#endif /* HAVE_IF_NAMETOINDEX || _WIN32 */
- free(zoneid);
+ curlx_free(zoneid);
}
}
#else
if(!url)
return CURLE_OUT_OF_MEMORY;
if(data->state.url_alloc)
- free(data->state.url);
+ curlx_free(data->state.url);
data->state.url = url;
data->state.url_alloc = TRUE;
}
if(uc)
return Curl_uc_to_curlcode(uc);
if(data->state.url_alloc)
- free(data->state.url);
+ curlx_free(data->state.url);
data->state.url = newurl;
data->state.url_alloc = TRUE;
}
}
/* make sure the connect struct gets its own copy of the hostname */
- conn->host.rawalloc = strdup(hostname ? hostname : "");
+ conn->host.rawalloc = curlx_strdup(hostname ? hostname : "");
if(!conn->host.rawalloc)
return CURLE_OUT_OF_MEMORY;
conn->host.name = conn->host.rawalloc;
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
if(uc) {
- free(url);
+ curlx_free(url);
return Curl_uc_to_curlcode(uc);
}
data->state.url = url;
uc = curl_url_get(uh, CURLUPART_OPTIONS, &data->state.up.options,
CURLU_URLDECODE);
if(!uc) {
- conn->options = strdup(data->state.up.options);
+ conn->options = curlx_strdup(data->state.up.options);
if(!conn->options)
return CURLE_OUT_OF_MEMORY;
}
s->resume_from = data->set.set_resume_from;
if(s->resume_from || data->set.str[STRING_SET_RANGE]) {
if(s->rangestringalloc)
- free(s->range);
+ curlx_free(s->range);
if(s->resume_from)
s->range = curl_maprintf("%" FMT_OFF_T "-", s->resume_from);
else
- s->range = strdup(data->set.str[STRING_SET_RANGE]);
+ s->range = curlx_strdup(data->set.str[STRING_SET_RANGE]);
if(!s->range)
return CURLE_OUT_OF_MEMORY;
goto error;
if(proxyuser || proxypasswd) {
- free(proxyinfo->user);
+ curlx_free(proxyinfo->user);
proxyinfo->user = proxyuser;
result = Curl_setstropt(&data->state.aptr.proxyuser, proxyuser);
proxyuser = NULL;
goto error;
Curl_safefree(proxyinfo->passwd);
if(!proxypasswd) {
- proxypasswd = strdup("");
+ proxypasswd = curlx_strdup("");
if(!proxypasswd) {
result = CURLE_OUT_OF_MEMORY;
goto error;
if(!curlx_str_number(&p, &num, UINT16_MAX))
proxyinfo->port = (uint16_t)num;
/* Should we not error out when the port number is invalid? */
- free(portptr);
+ curlx_free(portptr);
}
else {
if(data->set.proxyport)
/* path will be "/", if no path was found */
if(strcmp("/", path)) {
is_unix_proxy = TRUE;
- free(host);
+ curlx_free(host);
host = curl_maprintf(UNIX_SOCKET_PREFIX"%s", path);
if(!host) {
result = CURLE_OUT_OF_MEMORY;
goto error;
}
- free(proxyinfo->host.rawalloc);
+ curlx_free(proxyinfo->host.rawalloc);
proxyinfo->host.rawalloc = host;
proxyinfo->host.name = host;
host = NULL;
if(!is_unix_proxy) {
#endif
- free(proxyinfo->host.rawalloc);
+ curlx_free(proxyinfo->host.rawalloc);
proxyinfo->host.rawalloc = host;
if(host[0] == '[') {
/* this is a numerical IPv6, strip off the brackets */
#endif
error:
- free(proxyuser);
- free(proxypasswd);
- free(host);
- free(scheme);
+ curlx_free(proxyuser);
+ curlx_free(proxypasswd);
+ curlx_free(host);
+ curlx_free(scheme);
#ifdef USE_UNIX_SOCKETS
- free(path);
+ curlx_free(path);
#endif
curl_url_cleanup(uhp);
return result;
data->state.aptr.proxypasswd : "";
CURLcode result = CURLE_OUT_OF_MEMORY;
- conn->http_proxy.user = strdup(proxyuser);
+ conn->http_proxy.user = curlx_strdup(proxyuser);
if(conn->http_proxy.user) {
- conn->http_proxy.passwd = strdup(proxypasswd);
+ conn->http_proxy.passwd = curlx_strdup(proxypasswd);
if(conn->http_proxy.passwd)
result = CURLE_OK;
else
* Detect what (if any) proxy to use
*************************************************************/
if(data->set.str[STRING_PROXY]) {
- proxy = strdup(data->set.str[STRING_PROXY]);
+ proxy = curlx_strdup(data->set.str[STRING_PROXY]);
/* if global proxy is set, this is it */
if(!proxy) {
failf(data, "memory shortage");
}
if(data->set.str[STRING_PRE_PROXY]) {
- socksproxy = strdup(data->set.str[STRING_PRE_PROXY]);
+ socksproxy = curlx_strdup(data->set.str[STRING_PRE_PROXY]);
/* if global socks proxy is set, this is it */
if(!socksproxy) {
failf(data, "memory shortage");
#ifdef USE_UNIX_SOCKETS
/* For the time being do not mix proxy and Unix domain sockets. See #1274 */
if(proxy && conn->unix_domain_socket) {
- free(proxy);
+ curlx_free(proxy);
proxy = NULL;
}
#endif
if(proxy && (!*proxy || (conn->handler->flags & PROTOPT_NONETWORK))) {
- free(proxy); /* Do not bother with an empty proxy string or if the
- protocol does not work with network */
+ curlx_free(proxy); /* Do not bother with an empty proxy string
+ or if the protocol does not work with network */
proxy = NULL;
}
if(socksproxy && (!*socksproxy ||
(conn->handler->flags & PROTOPT_NONETWORK))) {
- free(socksproxy); /* Do not bother with an empty socks proxy string or if
- the protocol does not work with network */
+ curlx_free(socksproxy); /* Do not bother with an empty socks proxy string
+ or if the protocol does not work with
+ network */
socksproxy = NULL;
}
if(!conn->socks_proxy.user) {
conn->socks_proxy.user = conn->http_proxy.user;
conn->http_proxy.user = NULL;
- free(conn->socks_proxy.passwd);
+ curlx_free(conn->socks_proxy.passwd);
conn->socks_proxy.passwd = conn->http_proxy.passwd;
conn->http_proxy.passwd = NULL;
}
out:
- free(socksproxy);
- free(proxy);
+ curlx_free(socksproxy);
+ curlx_free(proxy);
return result;
}
#endif /* CURL_DISABLE_PROXY */
*passwdp = pbuf;
return CURLE_OK;
error:
- free(ubuf);
- free(pbuf);
+ curlx_free(ubuf);
+ curlx_free(pbuf);
return CURLE_OUT_OF_MEMORY;
}
char **optionsp = &conn->options;
if(data->set.str[STRING_OPTIONS]) {
- free(*optionsp);
- *optionsp = strdup(data->set.str[STRING_OPTIONS]);
+ curlx_free(*optionsp);
+ *optionsp = curlx_strdup(data->set.str[STRING_OPTIONS]);
if(!*optionsp)
return CURLE_OUT_OF_MEMORY;
}
}
}
if(url_provided) {
- free(conn->user);
- conn->user = strdup(*userp);
+ curlx_free(conn->user);
+ conn->user = curlx_strdup(*userp);
if(!conn->user)
return CURLE_OUT_OF_MEMORY;
}
/* no user was set but a password, set a blank user */
if(!*userp && *passwdp) {
- *userp = strdup("");
+ *userp = curlx_strdup("");
if(!*userp)
return CURLE_OUT_OF_MEMORY;
}
if(uc)
return Curl_uc_to_curlcode(uc);
if(!*userp) {
- *userp = strdup(data->state.aptr.user);
+ *userp = curlx_strdup(data->state.aptr.user);
if(!*userp)
return CURLE_OUT_OF_MEMORY;
}
if(uc)
return Curl_uc_to_curlcode(uc);
if(!*passwdp) {
- *passwdp = strdup(data->state.aptr.passwd);
+ *passwdp = curlx_strdup(data->state.aptr.passwd);
if(!*passwdp)
return CURLE_OUT_OF_MEMORY;
}
}
/* Store the default user */
if(!conn->user) {
- conn->user = strdup(setuser);
+ conn->user = curlx_strdup(setuser);
if(!conn->user)
return CURLE_OUT_OF_MEMORY;
}
/* Store the default password */
if(!conn->passwd) {
- conn->passwd = strdup(setpasswd);
+ conn->passwd = curlx_strdup(setpasswd);
if(!conn->passwd)
result = CURLE_OUT_OF_MEMORY;
}
if(!host || !*host)
return CURLE_OK;
- host_dup = strdup(host);
+ host_dup = curlx_strdup(host);
if(!host_dup)
return CURLE_OUT_OF_MEMORY;
/* now, clone the cleaned hostname */
DEBUGASSERT(hostptr);
- *hostname_result = strdup(hostptr);
+ *hostname_result = curlx_strdup(hostptr);
if(!*hostname_result) {
result = CURLE_OUT_OF_MEMORY;
goto error;
*port_result = port;
error:
- free(host_dup);
+ curlx_free(host_dup);
return result;
}
hostname_to_match_len = strlen(hostname_to_match);
host_match = curl_strnequal(ptr, hostname_to_match,
hostname_to_match_len);
- free(hostname_to_match);
+ curlx_free(hostname_to_match);
ptr += hostname_to_match_len;
host_match = host_match && *ptr == ':';
}
if(hit) {
- char *hostd = strdup((char *)as->dst.host);
+ char *hostd = curlx_strdup((char *)as->dst.host);
if(!hostd)
return CURLE_OUT_OF_MEMORY;
conn->conn_to_host.rawalloc = hostd;
/* Unix domain sockets are local. The host gets ignored, just use the
* specified domain socket address. Do not cache "DNS entries". There is
* no DNS involved and we already have the file system path available. */
- hostaddr = calloc(1, sizeof(struct Curl_dns_entry));
+ hostaddr = curlx_calloc(1, sizeof(struct Curl_dns_entry));
if(!hostaddr)
return CURLE_OUT_OF_MEMORY;
if(longpath)
/* Long paths are not supported for now */
failf(data, "Unix socket path too long: '%s'", unix_path);
- free(hostaddr);
+ curlx_free(hostaddr);
return longpath ? CURLE_COULDNT_RESOLVE_HOST : CURLE_OUT_OF_MEMORY;
}
}
/* Resolve target host right on */
- conn->hostname_resolve = strdup(ehost->name);
+ conn->hostname_resolve = curlx_strdup(ehost->name);
if(!conn->hostname_resolve)
return CURLE_OUT_OF_MEMORY;
* be new for this request even when we reuse an existing connection */
if(temp->user) {
/* use the new username and password though */
- free(existing->user);
- free(existing->passwd);
+ curlx_free(existing->user);
+ curlx_free(existing->passwd);
existing->user = temp->user;
existing->passwd = temp->passwd;
temp->user = NULL;
existing->bits.proxy_user_passwd = temp->bits.proxy_user_passwd;
if(existing->bits.proxy_user_passwd) {
/* use the new proxy username and proxy password though */
- free(existing->http_proxy.user);
- free(existing->socks_proxy.user);
- free(existing->http_proxy.passwd);
- free(existing->socks_proxy.passwd);
+ curlx_free(existing->http_proxy.user);
+ curlx_free(existing->socks_proxy.user);
+ curlx_free(existing->http_proxy.passwd);
+ curlx_free(existing->socks_proxy.passwd);
existing->http_proxy.user = temp->http_proxy.user;
existing->socks_proxy.user = temp->socks_proxy.user;
existing->http_proxy.passwd = temp->http_proxy.passwd;
existing->conn_to_port = temp->conn_to_port;
existing->remote_port = temp->remote_port;
- free(existing->hostname_resolve);
+ curlx_free(existing->hostname_resolve);
existing->hostname_resolve = temp->hostname_resolve;
temp->hostname_resolve = NULL;
goto out;
if(data->set.str[STRING_SASL_AUTHZID]) {
- conn->sasl_authzid = strdup(data->set.str[STRING_SASL_AUTHZID]);
+ conn->sasl_authzid = curlx_strdup(data->set.str[STRING_SASL_AUTHZID]);
if(!conn->sasl_authzid) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
if(data->set.str[STRING_BEARER]) {
- conn->oauth_bearer = strdup(data->set.str[STRING_BEARER]);
+ conn->oauth_bearer = curlx_strdup(data->set.str[STRING_BEARER]);
if(!conn->oauth_bearer) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#ifdef USE_UNIX_SOCKETS
if(data->set.str[STRING_UNIX_SOCKET_PATH]) {
- conn->unix_domain_socket = strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
+ conn->unix_domain_socket =
+ curlx_strdup(data->set.str[STRING_UNIX_SOCKET_PATH]);
if(!conn->unix_domain_socket) {
result = CURLE_OUT_OF_MEMORY;
goto out;
DEBUGASSERT(pnode);
if(pnode) {
*pnext = pnode->next;
- free(pnode);
+ curlx_free(pnode);
}
child->set.priority.parent = 0;
struct Curl_data_prio_node **tail;
struct Curl_data_prio_node *pnode;
- pnode = calloc(1, sizeof(*pnode));
+ pnode = curlx_calloc(1, sizeof(*pnode));
if(!pnode)
return CURLE_OUT_OF_MEMORY;
pnode->data = child;
#include "curlx/strparse.h"
#include "curl_memrchr.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
#ifdef _WIN32
/* MS-DOS/Windows style drive prefix, eg c: in c:foo */
#define STARTS_WITH_DRIVE_PREFIX(str) \
static void free_urlhandle(struct Curl_URL *u)
{
- free(u->scheme);
- free(u->user);
- free(u->password);
- free(u->options);
- free(u->host);
- free(u->zoneid);
- free(u->port);
- free(u->path);
- free(u->query);
- free(u->fragment);
+ curlx_free(u->scheme);
+ curlx_free(u->user);
+ curlx_free(u->password);
+ curlx_free(u->options);
+ curlx_free(u->host);
+ curlx_free(u->zoneid);
+ curlx_free(u->port);
+ curlx_free(u->path);
+ curlx_free(u->query);
+ curlx_free(u->fragment);
}
/*
result = CURLUE_USER_NOT_ALLOWED;
goto out;
}
- free(u->user);
+ curlx_free(u->user);
u->user = userp;
}
if(passwdp) {
- free(u->password);
+ curlx_free(u->password);
u->password = passwdp;
}
if(optionsp) {
- free(u->options);
+ curlx_free(u->options);
u->options = optionsp;
}
out:
- free(userp);
- free(passwdp);
- free(optionsp);
+ curlx_free(userp);
+ curlx_free(passwdp);
+ curlx_free(optionsp);
u->user = NULL;
u->password = NULL;
u->options = NULL;
u->portnum = (unsigned short) port;
/* generate a new port number string to get rid of leading zeroes etc */
- free(u->port);
+ curlx_free(u->port);
u->port = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port);
if(!u->port)
return CURLUE_OUT_OF_MEMORY;
if(!i || (']' != *h))
return CURLUE_BAD_IPV6;
zoneid[i] = 0;
- u->zoneid = strdup(zoneid);
+ u->zoneid = curlx_strdup(zoneid);
if(!u->zoneid)
return CURLUE_OUT_OF_MEMORY;
hostname[len] = ']'; /* insert end bracket */
return CURLUE_BAD_HOSTNAME;
curlx_dyn_reset(host);
result = curlx_dyn_addn(host, decoded, dlen);
- free(decoded);
+ curlx_free(decoded);
if(result)
return cc2cu(result);
}
if(result)
curlx_dyn_free(&host);
else {
- free(u->host);
+ curlx_free(u->host);
u->host = curlx_dyn_ptr(&host);
}
return result;
if(curlx_dyn_len(&out))
*outp = curlx_dyn_ptr(&out);
else {
- *outp = strdup("");
+ *outp = curlx_strdup("");
if(!*outp)
return 1;
}
path = &url[5];
pathlen = urllen - 5;
- u->scheme = strdup("file");
+ u->scheme = curlx_strdup("file");
if(!u->scheme) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
}
if(schemep) {
- u->scheme = strdup(schemep);
+ u->scheme = curlx_strdup(schemep);
if(!u->scheme) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
else
schemep = "http";
- u->scheme = strdup(schemep);
+ u->scheme = curlx_strdup(schemep);
if(!u->scheme) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
}
else {
/* single byte query */
- u->query = strdup("");
+ u->query = curlx_strdup("");
if(!u->query) {
result = CURLUE_OUT_OF_MEMORY;
goto fail;
goto fail;
}
if(dedot) {
- free(u->path);
+ curlx_free(u->path);
u->path = dedot;
}
}
*/
CURLU *curl_url(void)
{
- return calloc(1, sizeof(struct Curl_URL));
+ return curlx_calloc(1, sizeof(struct Curl_URL));
}
void curl_url_cleanup(CURLU *u)
{
if(u) {
free_urlhandle(u);
- free(u);
+ curlx_free(u);
}
}
#define DUP(dest, src, name) \
do { \
if(src->name) { \
- dest->name = strdup(src->name); \
+ dest->name = curlx_strdup(src->name); \
if(!dest->name) \
goto fail; \
} \
CURLU *curl_url_dup(const CURLU *in)
{
- struct Curl_URL *u = calloc(1, sizeof(struct Curl_URL));
+ struct Curl_URL *u = curlx_calloc(1, sizeof(struct Curl_URL));
if(u) {
DUP(u, in, scheme);
DUP(u, in, user);
/* this unconditional rejection of control bytes is documented
API behavior */
CURLcode res = Curl_urldecode(part, partlen, &decoded, &dlen, REJECT_CTRL);
- free(part);
+ curlx_free(part);
if(res)
return CURLUE_URLDECODE;
part = decoded;
struct dynbuf enc;
curlx_dyn_init(&enc, CURL_MAX_INPUT_LENGTH);
uc = urlencode_str(&enc, part, partlen, TRUE, what == CURLUPART_QUERY);
- free(part);
+ curlx_free(part);
if(uc)
return uc;
part = curlx_dyn_ptr(&enc);
if(!Curl_is_ASCII_name(u->host)) {
char *punyversion = NULL;
uc = host_decode(part, &punyversion);
- free(part);
+ curlx_free(part);
if(uc)
return uc;
part = punyversion;
if(Curl_is_ASCII_name(u->host)) {
char *unpunified = NULL;
uc = host_encode(part, &unpunified);
- free(part);
+ curlx_free(part);
if(uc)
return uc;
part = unpunified;
u->query ? u->query : "",
show_fragment ? "#": "",
u->fragment ? u->fragment : "");
- free(allochost);
+ curlx_free(allochost);
}
if(!url)
return CURLUE_OUT_OF_MEMORY;
tmp = curl_maprintf("%" CURL_FORMAT_CURL_OFF_T, port);
if(!tmp)
return CURLUE_OUT_OF_MEMORY;
- free(u->port);
+ curlx_free(u->port);
u->port = tmp;
u->portnum = (unsigned short)port;
return CURLUE_OK;
if(!uc) {
/* success, meaning the "" is a fine relative URL, but nothing
changes */
- free(oldurl);
+ curlx_free(oldurl);
return CURLUE_OK;
}
if(uc == CURLUE_OUT_OF_MEMORY)
DEBUGASSERT(oldurl); /* it is set here */
/* apply the relative part to create a new URL */
uc = redirect_url(oldurl, url, u, flags);
- free(oldurl);
+ curlx_free(oldurl);
return uc;
}
if(curlx_dyn_add(&qbuf, newp))
goto nomem;
curlx_dyn_free(&enc);
- free(*storep);
+ curlx_free(*storep);
*storep = curlx_dyn_ptr(&qbuf);
return CURLUE_OK;
nomem:
Curl_urldecode(newp, n, &decoded, &dlen, REJECT_CTRL);
if(result || hostname_check(u, decoded, dlen))
bad = TRUE;
- free(decoded);
+ curlx_free(decoded);
}
else if(hostname_check(u, (char *)CURL_UNCONST(newp), n))
bad = TRUE;
}
}
- free(*storep);
+ curlx_free(*storep);
*storep = (char *)CURL_UNCONST(newp);
}
return CURLUE_OK;
#include "../curlx/warnless.h"
#include "../sendf.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_create_plain_message()
*
#include "../curl_md5.h"
#include "../curlx/warnless.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_create_cram_md5_message()
#include "../curlx/strparse.h"
#include "../rand.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#ifndef USE_WINDOWS_SSPI
#define SESSION_ALGO 1 /* for algos with this bit set */
++s;
}
- dest = malloc(n);
+ dest = curlx_malloc(n);
if(dest) {
char *d = dest;
s = source;
/* Calculate H(A2) */
ctxt = Curl_MD5_init(&Curl_DIGEST_MD5);
if(!ctxt) {
- free(spn);
+ curlx_free(spn);
return CURLE_OUT_OF_MEMORY;
}
/* Now calculate the response hash */
ctxt = Curl_MD5_init(&Curl_DIGEST_MD5);
if(!ctxt) {
- free(spn);
+ curlx_free(spn);
return CURLE_OUT_OF_MEMORY;
}
"response=%s,qop=%s",
userp, realm, nonce,
cnonce, nonceCount, spn, resp_hash_hex, qop);
- free(spn);
+ curlx_free(spn);
if(!response)
return CURLE_OUT_OF_MEMORY;
/* Extract a value=content pair */
if(Curl_auth_digest_get_pair(chlg, value, content, &chlg)) {
if(curl_strequal(value, "nonce")) {
- free(digest->nonce);
- digest->nonce = strdup(content);
+ curlx_free(digest->nonce);
+ digest->nonce = curlx_strdup(content);
if(!digest->nonce)
return CURLE_OUT_OF_MEMORY;
}
}
}
else if(curl_strequal(value, "realm")) {
- free(digest->realm);
- digest->realm = strdup(content);
+ curlx_free(digest->realm);
+ digest->realm = curlx_strdup(content);
if(!digest->realm)
return CURLE_OUT_OF_MEMORY;
}
else if(curl_strequal(value, "opaque")) {
- free(digest->opaque);
- digest->opaque = strdup(content);
+ curlx_free(digest->opaque);
+ digest->opaque = curlx_strdup(content);
if(!digest->opaque)
return CURLE_OUT_OF_MEMORY;
}
/* Select only auth or auth-int. Otherwise, ignore */
if(foundAuth) {
- free(digest->qop);
- digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH);
+ curlx_free(digest->qop);
+ digest->qop = curlx_strdup(DIGEST_QOP_VALUE_STRING_AUTH);
if(!digest->qop)
return CURLE_OUT_OF_MEMORY;
}
else if(foundAuthInt) {
- free(digest->qop);
- digest->qop = strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT);
+ curlx_free(digest->qop);
+ digest->qop = curlx_strdup(DIGEST_QOP_VALUE_STRING_AUTH_INT);
if(!digest->qop)
return CURLE_OUT_OF_MEMORY;
}
}
else if(curl_strequal(value, "algorithm")) {
- free(digest->algorithm);
- digest->algorithm = strdup(content);
+ curlx_free(digest->algorithm);
+ digest->algorithm = curlx_strdup(content);
if(!digest->algorithm)
return CURLE_OUT_OF_MEMORY;
return CURLE_OUT_OF_MEMORY;
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
- free(hashthis);
+ curlx_free(hashthis);
if(result)
return result;
convert_to_ascii(hashbuf, (unsigned char *)userh);
return CURLE_OUT_OF_MEMORY;
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
- free(hashthis);
+ curlx_free(hashthis);
if(result)
return result;
convert_to_ascii(hashbuf, ha1);
return CURLE_OUT_OF_MEMORY;
result = hash(hashbuf, (unsigned char *) tmp, strlen(tmp));
- free(tmp);
+ curlx_free(tmp);
if(result)
return result;
convert_to_ascii(hashbuf, ha1);
result = hash(hashbuf, (const unsigned char *)"", 0);
if(result) {
- free(hashthis);
+ curlx_free(hashthis);
return result;
}
convert_to_ascii(hashbuf, (unsigned char *)hashed);
hashthis2 = curl_maprintf("%s:%s", hashthis, hashed);
- free(hashthis);
+ curlx_free(hashthis);
hashthis = hashthis2;
}
return CURLE_OUT_OF_MEMORY;
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
- free(hashthis);
+ curlx_free(hashthis);
if(result)
return result;
convert_to_ascii(hashbuf, ha2);
return CURLE_OUT_OF_MEMORY;
result = hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
- free(hashthis);
+ curlx_free(hashthis);
if(result)
return result;
convert_to_ascii(hashbuf, request_digest);
if(digest->realm)
realm_quoted = auth_digest_string_quoted(digest->realm);
else {
- realm_quoted = malloc(1);
+ realm_quoted = curlx_malloc(1);
if(realm_quoted)
realm_quoted[0] = 0;
}
if(!realm_quoted) {
- free(userp_quoted);
+ curlx_free(userp_quoted);
return CURLE_OUT_OF_MEMORY;
}
nonce_quoted = auth_digest_string_quoted(digest->nonce);
if(!nonce_quoted) {
- free(realm_quoted);
- free(userp_quoted);
+ curlx_free(realm_quoted);
+ curlx_free(userp_quoted);
return CURLE_OUT_OF_MEMORY;
}
uripath,
request_digest);
}
- free(nonce_quoted);
- free(realm_quoted);
- free(userp_quoted);
+ curlx_free(nonce_quoted);
+ curlx_free(realm_quoted);
+ curlx_free(userp_quoted);
if(!response)
return CURLE_OUT_OF_MEMORY;
/* Append the opaque */
opaque_quoted = auth_digest_string_quoted(digest->opaque);
if(!opaque_quoted) {
- free(response);
+ curlx_free(response);
return CURLE_OUT_OF_MEMORY;
}
tmp = curl_maprintf("%s, opaque=\"%s\"", response, opaque_quoted);
- free(response);
- free(opaque_quoted);
+ curlx_free(response);
+ curlx_free(opaque_quoted);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
if(digest->algorithm) {
/* Append the algorithm */
tmp = curl_maprintf("%s, algorithm=%s", response, digest->algorithm);
- free(response);
+ curlx_free(response);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
if(digest->userhash) {
/* Append the userhash */
tmp = curl_maprintf("%s, userhash=true", response);
- free(response);
+ curlx_free(response);
if(!tmp)
return CURLE_OUT_OF_MEMORY;
#include "../strcase.h"
#include "../strerror.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_is_digest_supported()
*
Curl_pSecFn->FreeContextBuffer(SecurityPackage);
/* Allocate our response buffer */
- output_token = malloc(token_max);
+ output_token = curlx_malloc(token_max);
if(!output_token)
return CURLE_OUT_OF_MEMORY;
/* Generate our SPN */
spn = Curl_auth_build_spn(service, data->conn->host.name, NULL);
if(!spn) {
- free(output_token);
+ curlx_free(output_token);
return CURLE_OUT_OF_MEMORY;
}
/* Populate our identity structure */
result = Curl_create_sspi_identity(userp, passwdp, &identity);
if(result) {
- free(spn);
- free(output_token);
+ curlx_free(spn);
+ curlx_free(output_token);
return result;
}
if(status != SEC_E_OK) {
Curl_sspi_free_identity(p_identity);
- free(spn);
- free(output_token);
+ curlx_free(spn);
+ curlx_free(output_token);
return CURLE_LOGIN_DENIED;
}
Curl_pSecFn->FreeCredentialsHandle(&credentials);
Curl_sspi_free_identity(p_identity);
- free(spn);
- free(output_token);
+ curlx_free(spn);
+ curlx_free(output_token);
if(status == SEC_E_INSUFFICIENT_MEMORY)
return CURLE_OUT_OF_MEMORY;
Curl_sspi_free_identity(p_identity);
/* Free the SPN */
- free(spn);
+ curlx_free(spn);
return result;
}
if(!domain.tchar_ptr)
return CURLE_OUT_OF_MEMORY;
- dup_domain.tchar_ptr = Curl_tcsdup(domain.tchar_ptr);
+ dup_domain.tchar_ptr = curlx_tcsdup(domain.tchar_ptr);
if(!dup_domain.tchar_ptr) {
curlx_unicodefree(domain.tchar_ptr);
return CURLE_OUT_OF_MEMORY;
}
- free(identity->Domain);
+ curlx_free(identity->Domain);
identity->Domain = dup_domain.tbyte_ptr;
identity->DomainLength = curlx_uztoul(_tcslen(dup_domain.tchar_ptr));
dup_domain.tchar_ptr = NULL;
/* Allocate the output buffer according to the max token size as indicated
by the security package */
- output_token = malloc(token_max);
+ output_token = curlx_malloc(token_max);
if(!output_token) {
return CURLE_OUT_OF_MEMORY;
}
if(userp && *userp) {
/* Populate our identity structure */
if(Curl_create_sspi_identity(userp, passwdp, &identity)) {
- free(output_token);
+ curlx_free(output_token);
return CURLE_OUT_OF_MEMORY;
}
if(Curl_override_sspi_http_realm((const char *) digest->input_token,
&identity)) {
Curl_sspi_free_identity(&identity);
- free(output_token);
+ curlx_free(output_token);
return CURLE_OUT_OF_MEMORY;
}
p_identity = NULL;
if(userp) {
- digest->user = strdup(userp);
+ digest->user = curlx_strdup(userp);
if(!digest->user) {
- free(output_token);
+ curlx_free(output_token);
Curl_sspi_free_identity(p_identity);
return CURLE_OUT_OF_MEMORY;
}
}
if(passwdp) {
- digest->passwd = strdup(passwdp);
+ digest->passwd = curlx_strdup(passwdp);
if(!digest->passwd) {
- free(output_token);
+ curlx_free(output_token);
Curl_sspi_free_identity(p_identity);
Curl_safefree(digest->user);
return CURLE_OUT_OF_MEMORY;
&credentials, NULL);
if(status != SEC_E_OK) {
Curl_sspi_free_identity(p_identity);
- free(output_token);
+ curlx_free(output_token);
return CURLE_LOGIN_DENIED;
}
Curl_pSecFn->FreeCredentialsHandle(&credentials);
Curl_sspi_free_identity(p_identity);
- free(output_token);
+ curlx_free(output_token);
return CURLE_OUT_OF_MEMORY;
}
/* Allocate our new context handle */
- digest->http_context = calloc(1, sizeof(CtxtHandle));
+ digest->http_context = curlx_calloc(1, sizeof(CtxtHandle));
if(!digest->http_context) {
Curl_pSecFn->FreeCredentialsHandle(&credentials);
curlx_unicodefree(spn);
Curl_sspi_free_identity(p_identity);
- free(output_token);
+ curlx_free(output_token);
return CURLE_OUT_OF_MEMORY;
}
Curl_pSecFn->FreeCredentialsHandle(&credentials);
Curl_sspi_free_identity(p_identity);
- free(output_token);
+ curlx_free(output_token);
Curl_safefree(digest->http_context);
}
resp = Curl_memdup0((const char *)output_token, output_token_len);
- free(output_token);
+ curlx_free(output_token);
if(!resp) {
return CURLE_OUT_OF_MEMORY;
}
#include <gsasl.h>
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
bool Curl_auth_gsasl_is_supported(struct Curl_easy *data,
const char *mech,
struct gsasldata *gsasl)
#include "../curl_gssapi.h"
#include "../sendf.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#if defined(__GNUC__) && defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Curl_gss_log_error(data, "gss_import_name() failed: ",
major_status, minor_status);
- free(spn);
+ curlx_free(spn);
return CURLE_AUTH_ERROR;
}
- free(spn);
+ curlx_free(spn);
}
if(chlg) {
messagelen = 4;
if(authzid)
messagelen += strlen(authzid);
- message = malloc(messagelen);
+ message = curlx_malloc(messagelen);
if(!message)
return CURLE_OUT_OF_MEMORY;
if(GSS_ERROR(major_status)) {
Curl_gss_log_error(data, "gss_wrap() failed: ",
major_status, minor_status);
- free(message);
+ curlx_free(message);
return CURLE_AUTH_ERROR;
}
gss_release_buffer(&unused_status, &output_token);
/* Free the message buffer */
- free(message);
+ curlx_free(message);
return result;
}
#include "../curlx/multibyte.h"
#include "../sendf.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_is_gssapi_supported()
*
Curl_pSecFn->FreeContextBuffer(SecurityPackage);
/* Allocate our response buffer */
- krb5->output_token = malloc(krb5->token_max);
+ krb5->output_token = curlx_malloc(krb5->token_max);
if(!krb5->output_token)
return CURLE_OUT_OF_MEMORY;
}
krb5->p_identity = NULL;
/* Allocate our credentials handle */
- krb5->credentials = calloc(1, sizeof(CredHandle));
+ krb5->credentials = curlx_calloc(1, sizeof(CredHandle));
if(!krb5->credentials)
return CURLE_OUT_OF_MEMORY;
return CURLE_LOGIN_DENIED;
/* Allocate our new context handle */
- krb5->context = calloc(1, sizeof(CtxtHandle));
+ krb5->context = curlx_calloc(1, sizeof(CtxtHandle));
if(!krb5->context)
return CURLE_OUT_OF_MEMORY;
}
}
/* Allocate the trailer */
- trailer = malloc(sizes.cbSecurityTrailer);
+ trailer = curlx_malloc(sizes.cbSecurityTrailer);
if(!trailer)
return CURLE_OUT_OF_MEMORY;
messagelen = 4;
if(authzid)
messagelen += strlen(authzid);
- message = malloc(messagelen);
+ message = curlx_malloc(messagelen);
if(!message) {
result = CURLE_OUT_OF_MEMORY;
goto out;
memcpy(message + 4, authzid, messagelen - 4);
/* Allocate the padding */
- padding = malloc(sizes.cbBlockSize);
+ padding = curlx_malloc(sizes.cbBlockSize);
if(!padding) {
result = CURLE_OUT_OF_MEMORY;
goto out;
/* Allocate the encryption (wrap) buffer */
appdatalen = wrap_buf[0].cbBuffer + wrap_buf[1].cbBuffer +
wrap_buf[2].cbBuffer;
- appdata = malloc(appdatalen);
+ appdata = curlx_malloc(appdatalen);
if(!appdata) {
result = CURLE_OUT_OF_MEMORY;
goto out;
out:
/* Free all of our local buffers */
- free(padding);
- free(message);
- free(trailer);
+ curlx_free(padding);
+ curlx_free(message);
+ curlx_free(trailer);
if(result)
return result;
/* Free our security context */
if(krb5->context) {
Curl_pSecFn->DeleteSecurityContext(krb5->context);
- free(krb5->context);
+ curlx_free(krb5->context);
krb5->context = NULL;
}
/* Free our credentials handle */
if(krb5->credentials) {
Curl_pSecFn->FreeCredentialsHandle(krb5->credentials);
- free(krb5->credentials);
+ curlx_free(krb5->credentials);
krb5->credentials = NULL;
}
#include "vauth.h"
#include "../curl_endian.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* NTLM buffer fixed size, large enough for long user + host + domain */
#define NTLM_BUFSIZE 1024
return CURLE_BAD_CONTENT_ENCODING;
}
- free(ntlm->target_info); /* replace any previous data */
+ curlx_free(ntlm->target_info); /* replace any previous data */
ntlm->target_info = Curl_memdup(&type2[target_info_offset],
target_info_len);
if(!ntlm->target_info)
result = Curl_bufref_memdup(out, ntlmbuf, size);
error:
- free(ntlmv2resp); /* Free the dynamic buffer allocated for NTLMv2 */
+ curlx_free(ntlmv2resp); /* Free the dynamic buffer allocated for NTLMv2 */
Curl_auth_cleanup_ntlm(ntlm);
#include "../sendf.h"
#include "../strdup.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_is_ntlm_supported()
*
Curl_pSecFn->FreeContextBuffer(SecurityPackage);
/* Allocate our output buffer */
- ntlm->output_token = malloc(ntlm->token_max);
+ ntlm->output_token = curlx_malloc(ntlm->token_max);
if(!ntlm->output_token)
return CURLE_OUT_OF_MEMORY;
ntlm->p_identity = NULL;
/* Allocate our credentials handle */
- ntlm->credentials = calloc(1, sizeof(CredHandle));
+ ntlm->credentials = curlx_calloc(1, sizeof(CredHandle));
if(!ntlm->credentials)
return CURLE_OUT_OF_MEMORY;
return CURLE_LOGIN_DENIED;
/* Allocate our new context handle */
- ntlm->context = calloc(1, sizeof(CtxtHandle));
+ ntlm->context = curlx_calloc(1, sizeof(CtxtHandle));
if(!ntlm->context)
return CURLE_OUT_OF_MEMORY;
/* Free our security context */
if(ntlm->context) {
Curl_pSecFn->DeleteSecurityContext(ntlm->context);
- free(ntlm->context);
+ curlx_free(ntlm->context);
ntlm->context = NULL;
}
/* Free our credentials handle */
if(ntlm->credentials) {
Curl_pSecFn->FreeCredentialsHandle(ntlm->credentials);
- free(ntlm->credentials);
+ curlx_free(ntlm->credentials);
ntlm->credentials = NULL;
}
#include "vauth.h"
#include "../curlx/warnless.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_create_oauth_bearer_message()
*
#include "../curlx/multibyte.h"
#include "../sendf.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#if defined(__GNUC__) && defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
Curl_gss_log_error(data, "gss_import_name() failed: ",
major_status, minor_status);
- free(spn);
+ curlx_free(spn);
return CURLE_AUTH_ERROR;
}
- free(spn);
+ curlx_free(spn);
}
if(chlg64 && *chlg64) {
#include "../sendf.h"
#include "../strerror.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_is_spnego_supported()
*
Curl_pSecFn->FreeContextBuffer(SecurityPackage);
/* Allocate our output buffer */
- nego->output_token = malloc(nego->token_max);
+ nego->output_token = curlx_malloc(nego->token_max);
if(!nego->output_token)
return CURLE_OUT_OF_MEMORY;
}
nego->p_identity = NULL;
/* Allocate our credentials handle */
- nego->credentials = calloc(1, sizeof(CredHandle));
+ nego->credentials = curlx_calloc(1, sizeof(CredHandle));
if(!nego->credentials)
return CURLE_OUT_OF_MEMORY;
return CURLE_AUTH_ERROR;
/* Allocate our new context handle */
- nego->context = calloc(1, sizeof(CtxtHandle));
+ nego->context = curlx_calloc(1, sizeof(CtxtHandle));
if(!nego->context)
return CURLE_OUT_OF_MEMORY;
}
&resp_desc, &attrs, NULL);
/* Free the decoded challenge as it is not required anymore */
- free(chlg);
+ curlx_free(chlg);
if(GSS_ERROR(nego->status)) {
char buffer[STRERROR_LEN];
nego->output_token_length, outptr,
outlen);
if(!result && (!*outptr || !*outlen)) {
- free(*outptr);
+ curlx_free(*outptr);
result = CURLE_REMOTE_ACCESS_DENIED;
}
/* Free our security context */
if(nego->context) {
Curl_pSecFn->DeleteSecurityContext(nego->context);
- free(nego->context);
+ curlx_free(nego->context);
nego->context = NULL;
}
/* Free our credentials handle */
if(nego->credentials) {
Curl_pSecFn->FreeCredentialsHandle(nego->credentials);
- free(nego->credentials);
+ curlx_free(nego->credentials);
nego->credentials = NULL;
}
#include "../curlx/multibyte.h"
#include "../url.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Curl_auth_build_spn()
*
must be freed by curlx_unicodefree we will dupe the result so that the
pointer this function returns can be normally free'd. */
tchar_spn = curlx_convert_UTF8_to_tchar(utf8_spn);
- free(utf8_spn);
+ curlx_free(utf8_spn);
if(!tchar_spn)
return NULL;
- dupe_tchar_spn = Curl_tcsdup(tchar_spn);
+ dupe_tchar_spn = curlx_tcsdup(tchar_spn);
curlx_unicodefree(tchar_spn);
return dupe_tchar_spn;
}
(void)klen;
DEBUGASSERT(ntlm);
Curl_auth_cleanup_ntlm(ntlm);
- free(ntlm);
+ curlx_free(ntlm);
}
struct ntlmdata *Curl_auth_ntlm_get(struct connectdata *conn, bool proxy)
CURL_META_NTLM_CONN;
struct ntlmdata *ntlm = Curl_conn_meta_get(conn, key);
if(!ntlm) {
- ntlm = calloc(1, sizeof(*ntlm));
+ ntlm = curlx_calloc(1, sizeof(*ntlm));
if(!ntlm ||
Curl_conn_meta_set(conn, key, ntlm, ntlm_conn_dtor))
return NULL;
(void)klen;
DEBUGASSERT(krb5);
Curl_auth_cleanup_gssapi(krb5);
- free(krb5);
+ curlx_free(krb5);
}
struct kerberos5data *Curl_auth_krb5_get(struct connectdata *conn)
{
struct kerberos5data *krb5 = Curl_conn_meta_get(conn, CURL_META_KRB5_CONN);
if(!krb5) {
- krb5 = calloc(1, sizeof(*krb5));
+ krb5 = curlx_calloc(1, sizeof(*krb5));
if(!krb5 ||
Curl_conn_meta_set(conn, CURL_META_KRB5_CONN, krb5, krb5_conn_dtor))
return NULL;
(void)klen;
DEBUGASSERT(gsasl);
Curl_auth_gsasl_cleanup(gsasl);
- free(gsasl);
+ curlx_free(gsasl);
}
struct gsasldata *Curl_auth_gsasl_get(struct connectdata *conn)
{
struct gsasldata *gsasl = Curl_conn_meta_get(conn, CURL_META_GSASL_CONN);
if(!gsasl) {
- gsasl = calloc(1, sizeof(*gsasl));
+ gsasl = curlx_calloc(1, sizeof(*gsasl));
if(!gsasl ||
Curl_conn_meta_set(conn, CURL_META_GSASL_CONN, gsasl, gsasl_conn_dtor))
return NULL;
(void)klen;
DEBUGASSERT(nego);
Curl_auth_cleanup_spnego(nego);
- free(nego);
+ curlx_free(nego);
}
struct negotiatedata *Curl_auth_nego_get(struct connectdata *conn, bool proxy)
CURL_META_NEGO_CONN;
struct negotiatedata *nego = Curl_conn_meta_get(conn, key);
if(!nego) {
- nego = calloc(1, sizeof(*nego));
+ nego = curlx_calloc(1, sizeof(*nego));
if(!nego ||
Curl_conn_meta_set(conn, key, nego, nego_conn_dtor))
return NULL;
#include "../curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#define QUIC_MAX_STREAMS (256*1024)
#define QUIC_HANDSHAKE_TIMEOUT (10*NGTCP2_SECONDS)
Curl_uint32_hash_destroy(&ctx->streams);
Curl_ssl_peer_cleanup(&ctx->peer);
}
- free(ctx);
+ curlx_free(ctx);
}
static void cf_ngtcp2_setup_keep_alive(struct Curl_cfilter *cf,
{
Curl_bufq_free(&stream->sendbuf);
Curl_h1_req_parse_free(&stream->h1);
- free(stream);
+ curlx_free(stream);
}
static void h3_stream_hash_free(unsigned int id, void *stream)
if(stream)
return CURLE_OK;
- stream = calloc(1, sizeof(*stream));
+ stream = curlx_calloc(1, sizeof(*stream));
if(!stream)
return CURLE_OUT_OF_MEMORY;
Curl_h1_req_parse_free(&stream->h1);
nheader = Curl_dynhds_count(&h2_headers);
- nva = malloc(sizeof(nghttp3_nv) * nheader);
+ nva = curlx_malloc(sizeof(nghttp3_nv) * nheader);
if(!nva) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
out:
- free(nva);
+ curlx_free(nva);
Curl_dynhds_free(&h2_headers);
return result;
}
CURLcode result;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "../curlx/warnless.h"
#include "../curlx/strerr.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* A stream window is the maximum amount we need to buffer for
* each active transfer. We use HTTP/3 flow control and only ACK
* when we take things out of the buffer.
Curl_bufcp_free(&ctx->stream_bufcp);
Curl_uint32_hash_destroy(&ctx->streams);
Curl_ssl_peer_cleanup(&ctx->peer);
- free(ctx->poll_items);
- free(ctx->curl_items);
+ curlx_free(ctx->poll_items);
+ curlx_free(ctx->curl_items);
}
- free(ctx);
+ curlx_free(ctx);
}
static void cf_osslq_ctx_close(struct cf_osslq_ctx *ctx)
Curl_bufq_free(&stream->sendbuf);
Curl_bufq_free(&stream->recvbuf);
Curl_h1_req_parse_free(&stream->h1);
- free(stream);
+ curlx_free(stream);
}
static void h3_stream_hash_free(unsigned int id, void *stream)
if(stream)
return CURLE_OK;
- stream = calloc(1, sizeof(*stream));
+ stream = curlx_calloc(1, sizeof(*stream));
if(!stream)
return CURLE_OUT_OF_MEMORY;
if(ctx->items_max < Curl_uint32_hash_count(&ctx->streams)) {
size_t nmax = Curl_uint32_hash_count(&ctx->streams);
ctx->items_max = 0;
- tmpptr = realloc(ctx->poll_items, nmax * sizeof(SSL_POLL_ITEM));
+ tmpptr = curlx_realloc(ctx->poll_items, nmax * sizeof(SSL_POLL_ITEM));
if(!tmpptr) {
- free(ctx->poll_items);
+ curlx_free(ctx->poll_items);
ctx->poll_items = NULL;
res = CURLE_OUT_OF_MEMORY;
goto out;
}
ctx->poll_items = tmpptr;
- tmpptr = realloc(ctx->curl_items, nmax * sizeof(struct Curl_easy *));
+ tmpptr = curlx_realloc(ctx->curl_items,
+ nmax * sizeof(struct Curl_easy *));
if(!tmpptr) {
- free(ctx->curl_items);
+ curlx_free(ctx->curl_items);
ctx->curl_items = NULL;
res = CURLE_OUT_OF_MEMORY;
goto out;
Curl_h1_req_parse_free(&stream->h1);
nheader = Curl_dynhds_count(&h2_headers);
- nva = malloc(sizeof(nghttp3_nv) * nheader);
+ nva = curlx_malloc(sizeof(nghttp3_nv) * nheader);
if(!nva) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
out:
- free(nva);
+ curlx_free(nva);
Curl_dynhds_free(&h2_headers);
return result;
}
CURLcode result;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "../vtls/keylog.h"
#include "../vtls/vtls.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* HTTP/3 error values defined in RFC 9114, ch. 8.1 */
#define CURL_H3_NO_ERROR (0x0100)
Curl_bufcp_free(&ctx->stream_bufcp);
Curl_uint32_hash_destroy(&ctx->streams);
}
- free(ctx);
+ curlx_free(ctx);
}
static void cf_quiche_ctx_close(struct cf_quiche_ctx *ctx)
{
Curl_bufq_free(&stream->recvbuf);
Curl_h1_req_parse_free(&stream->h1);
- free(stream);
+ curlx_free(stream);
}
static void h3_stream_hash_free(unsigned int id, void *stream)
if(stream)
return CURLE_OK;
- stream = calloc(1, sizeof(*stream));
+ stream = curlx_calloc(1, sizeof(*stream));
if(!stream)
return CURLE_OUT_OF_MEMORY;
Curl_h1_req_parse_free(&stream->h1);
nheader = Curl_dynhds_count(&h2_headers);
- nva = malloc(sizeof(quiche_h3_header) * nheader);
+ nva = curlx_malloc(sizeof(quiche_h3_header) * nheader);
if(!nva) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
out:
- free(nva);
+ curlx_free(nva);
Curl_dynhds_free(&h2_headers);
return result;
}
(void)data;
(void)conn;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "../vtls/vtls_scache.h"
#include "vquic-tls.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
CURLcode Curl_vquic_tls_init(struct curl_tls_ctx *ctx,
struct Curl_cfilter *cf,
struct Curl_easy *data,
#include "../curlx/strerr.h"
#include "../curlx/strparse.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#if !defined(CURL_DISABLE_HTTP) && defined(USE_HTTP3)
*qlogfdp = qlogfd;
}
curlx_dyn_free(&fname);
- free(qlog_dir);
+ curlx_free(qlog_dir);
if(result)
return result;
}
#include <fcntl.h>
#endif
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* A recent macro provided by libssh. Or make our own. */
#ifndef SSH_STRING_FREE_CHAR
#define SSH_STRING_FREE_CHAR(x) \
cleanup:
if(found_base64) {
- (free)(found_base64);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(found_base64); /* allocated by libssh, deallocate with system free */
}
if(known_base64) {
- (free)(known_base64);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(known_base64); /* allocated by libssh, deallocate with system free */
}
if(hash)
ssh_clean_pubkey_hash(&hash);
}
result = Curl_client_write(data, CLIENTWRITE_BODY,
tmpLine, sshc->readdir_len + 1);
- free(tmpLine);
+ curlx_free(tmpLine);
if(result) {
myssh_to(data, sshc, SSH_STOP);
if(!result) {
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
- free(tmp);
+ curlx_free(tmp);
}
if(result) {
myssh_to(data, sshc, SSH_SFTP_CLOSE);
if(!sshc->homedir)
return myssh_to_ERROR(data, sshc, CURLE_COULDNT_CONNECT);
- free(data->state.most_recent_ftp_entrypath);
- data->state.most_recent_ftp_entrypath = strdup(sshc->homedir);
+ curlx_free(data->state.most_recent_ftp_entrypath);
+ data->state.most_recent_ftp_entrypath = curlx_strdup(sshc->homedir);
if(!data->state.most_recent_ftp_entrypath)
return myssh_to_ERROR(data, sshc, CURLE_OUT_OF_MEMORY);
the current directory can be read similar to how it is read when
using ordinary FTP. */
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
- free(tmp);
+ curlx_free(tmp);
if(result) {
myssh_to(data, sshc, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
(void)key;
(void)klen;
Curl_safefree(sshp->path);
- free(sshp);
+ curlx_free(sshp);
}
static void myssh_conn_dtor(void *key, size_t klen, void *entry)
(void)key;
(void)klen;
sshc_cleanup(sshc);
- free(sshc);
+ curlx_free(sshc);
}
/*
struct SSHPROTO *sshp;
struct ssh_conn *sshc;
- sshc = calloc(1, sizeof(*sshc));
+ sshc = curlx_calloc(1, sizeof(*sshc));
if(!sshc)
return CURLE_OUT_OF_MEMORY;
if(Curl_conn_meta_set(conn, CURL_META_SSH_CONN, sshc, myssh_conn_dtor))
return CURLE_OUT_OF_MEMORY;
- sshp = calloc(1, sizeof(*sshp));
+ sshp = curlx_calloc(1, sizeof(*sshp));
if(!sshp ||
Curl_meta_set(data, CURL_META_SSH_EASY, sshp, myssh_easy_dtor))
return CURLE_OUT_OF_MEMORY;
#include "../curlx/strparse.h"
#include "../curlx/base64.h" /* for base64 encoding/decoding */
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* Local functions: */
static const char *sftp_libssh2_strerror(unsigned long err);
static LIBSSH2_ALLOC_FUNC(my_libssh2_malloc);
#endif /* CURL_LIBSSH2_DEBUG */
if(num_prompts == 1) {
struct connectdata *conn = data->conn;
- responses[0].text = strdup(conn->passwd);
+ responses[0].text = curlx_strdup(conn->passwd);
responses[0].length =
responses[0].text == NULL ? 0 : curlx_uztoui(strlen(conn->passwd));
}
failf(data,
"Denied establishing ssh session: mismatch sha256 fingerprint. "
"Remote %s is not equal to %s", fingerprint_b64, pubkey_sha256);
- free(fingerprint_b64);
+ curlx_free(fingerprint_b64);
myssh_state(data, sshc, SSH_SESSION_FREE);
return CURLE_PEER_FAILED_VERIFICATION;
}
- free(fingerprint_b64);
+ curlx_free(fingerprint_b64);
infof(data, "SHA256 checksum match");
}
the current directory can be read similar to how it is read when
using ordinary FTP. */
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
- free(tmp);
+ curlx_free(tmp);
if(!result)
myssh_state(data, sshc, SSH_SFTP_NEXT_QUOTE);
return result;
sshc->rsa_pub = sshc->rsa = NULL;
if(data->set.str[STRING_SSH_PRIVATE_KEY])
- sshc->rsa = strdup(data->set.str[STRING_SSH_PRIVATE_KEY]);
+ sshc->rsa = curlx_strdup(data->set.str[STRING_SSH_PRIVATE_KEY]);
else {
/* To ponder about: should really the lib be messing about with the
HOME environment variable etc? */
if(!sshc->rsa)
out_of_memory = TRUE;
else if(curlx_stat(sshc->rsa, &sbuf)) {
- free(sshc->rsa);
+ curlx_free(sshc->rsa);
sshc->rsa = curl_maprintf("%s/.ssh/id_dsa", home);
if(!sshc->rsa)
out_of_memory = TRUE;
Curl_safefree(sshc->rsa);
}
}
- free(home);
+ curlx_free(home);
}
if(!out_of_memory && !sshc->rsa) {
/* Nothing found; try the current dir. */
- sshc->rsa = strdup("id_rsa");
+ sshc->rsa = curlx_strdup("id_rsa");
if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
- free(sshc->rsa);
- sshc->rsa = strdup("id_dsa");
+ curlx_free(sshc->rsa);
+ sshc->rsa = curlx_strdup("id_dsa");
if(sshc->rsa && curlx_stat(sshc->rsa, &sbuf)) {
- free(sshc->rsa);
+ curlx_free(sshc->rsa);
/* Out of guesses. Set to the empty string to avoid
* surprising info messages. */
- sshc->rsa = strdup("");
+ sshc->rsa = curlx_strdup("");
}
}
}
if(data->set.str[STRING_SSH_PUBLIC_KEY]
/* treat empty string the same way as NULL */
&& data->set.str[STRING_SSH_PUBLIC_KEY][0]) {
- sshc->rsa_pub = strdup(data->set.str[STRING_SSH_PUBLIC_KEY]);
+ sshc->rsa_pub = curlx_strdup(data->set.str[STRING_SSH_PUBLIC_KEY]);
if(!sshc->rsa_pub)
out_of_memory = TRUE;
}
myssh_state(data, sshc, SSH_STOP);
if(rc > 0) {
- free(sshc->homedir);
- sshc->homedir = strdup(sshp->readdir_filename);
+ curlx_free(sshc->homedir);
+ sshc->homedir = curlx_strdup(sshp->readdir_filename);
if(!sshc->homedir)
return CURLE_OUT_OF_MEMORY;
- free(data->state.most_recent_ftp_entrypath);
- data->state.most_recent_ftp_entrypath = strdup(sshc->homedir);
+ curlx_free(data->state.most_recent_ftp_entrypath);
+ data->state.most_recent_ftp_entrypath = curlx_strdup(sshc->homedir);
if(!data->state.most_recent_ftp_entrypath)
return CURLE_OUT_OF_MEMORY;
}
}
result = Curl_client_write(data, CLIENTWRITE_HEADER, tmp, strlen(tmp));
- free(tmp);
+ curlx_free(tmp);
if(result) {
myssh_state(data, sshc, SSH_SFTP_CLOSE);
sshc->nextstate = SSH_NO_STATE;
Curl_safefree(sshp->path);
curlx_dyn_free(&sshp->readdir);
curlx_dyn_free(&sshp->readdir_link);
- free(sshp);
+ curlx_free(sshp);
}
static void myssh_conn_dtor(void *key, size_t klen, void *entry)
(void)key;
(void)klen;
sshc_cleanup(sshc, NULL, TRUE);
- free(sshc);
+ curlx_free(sshc);
}
/*
struct SSHPROTO *sshp;
(void)conn;
- sshc = calloc(1, sizeof(*sshc));
+ sshc = curlx_calloc(1, sizeof(*sshc));
if(!sshc)
return CURLE_OUT_OF_MEMORY;
if(Curl_conn_meta_set(conn, CURL_META_SSH_CONN, sshc, myssh_conn_dtor))
return CURLE_OUT_OF_MEMORY;
- sshp = calloc(1, sizeof(*sshp));
+ sshp = curlx_calloc(1, sizeof(*sshp));
if(!sshp)
return CURLE_OUT_OF_MEMORY;
#include <curl/curl.h>
#include "../curlx/strparse.h"
#include "../curl_trc.h"
-#include "../curl_memory.h"
#include "../escape.h"
-#include "../memdebug.h"
#define MAX_SSHPATH_LEN 100000 /* arbitrary */
(working_path_len > 3) && (!memcmp(working_path, "/~/", 3))) {
/* It is referenced to the home directory, so strip the leading '/~/' */
if(curlx_dyn_addn(&npath, &working_path[3], working_path_len - 3)) {
- free(working_path);
+ curlx_free(working_path);
return CURLE_OUT_OF_MEMORY;
}
}
(!strcmp("/~", working_path) ||
((working_path_len > 2) && !memcmp(working_path, "/~/", 3)))) {
if(curlx_dyn_add(&npath, homedir)) {
- free(working_path);
+ curlx_free(working_path);
return CURLE_OUT_OF_MEMORY;
}
if(working_path_len > 2) {
if(curlx_dyn_addn(&npath, &working_path[copyfrom],
working_path_len - copyfrom)) {
- free(working_path);
+ curlx_free(working_path);
return CURLE_OUT_OF_MEMORY;
}
}
else {
if(curlx_dyn_add(&npath, "/")) {
- free(working_path);
+ curlx_free(working_path);
return CURLE_OUT_OF_MEMORY;
}
}
}
if(curlx_dyn_len(&npath)) {
- free(working_path);
+ curlx_free(working_path);
/* store the pointer for the caller to receive */
*path = curlx_dyn_ptr(&npath);
#include <Security/Security.h>
#endif
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#ifdef USE_APPLE_SECTRUST
#define SSL_SYSTEM_VERIFIER
if(error_ref) {
CFIndex size = CFStringGetMaximumSizeForEncoding(
CFStringGetLength(error_ref), kCFStringEncodingUTF8);
- err_desc = malloc(size + 1);
+ err_desc = curlx_malloc(size + 1);
if(err_desc) {
if(!CFStringGetCString(error_ref, err_desc, size,
kCFStringEncodingUTF8)) {
- free(err_desc);
+ curlx_free(err_desc);
err_desc = NULL;
}
}
}
out:
- free(err_desc);
+ curlx_free(err_desc);
if(error_ref)
CFRelease(error_ref);
if(error)
#include "../curlx/warnless.h"
#include "x509asn1.h"
#include "../multiif.h"
-#include "../curl_memory.h"
-/* The last #include file should be: */
-#include "../memdebug.h"
/* Enable GnuTLS debugging by defining GTLSDEBUG */
/*#define GTLSDEBUG */
if(fseek(f, 0, SEEK_END) != 0
|| (filelen = ftell(f)) < 0
|| fseek(f, 0, SEEK_SET) != 0
- || !(ptr = malloc((size_t)filelen)))
+ || !(ptr = curlx_malloc((size_t)filelen)))
goto out;
if(fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) {
- free(ptr);
+ curlx_free(ptr);
goto out;
}
static void unload_file(gnutls_datum_t data)
{
- free(data.data);
+ curlx_free(data.data);
}
int rc;
*pcreds = NULL;
- shared = calloc(1, sizeof(*shared));
+ shared = curlx_calloc(1, sizeof(*shared));
if(!shared)
return CURLE_OUT_OF_MEMORY;
rc = gnutls_certificate_allocate_credentials(&shared->creds);
if(rc != GNUTLS_E_SUCCESS) {
failf(data, "gnutls_cert_all_cred() failed: %s", gnutls_strerror(rc));
- free(shared);
+ curlx_free(shared);
return CURLE_SSL_CONNECT_ERROR;
}
--shared->refcount;
if(!shared->refcount) {
gnutls_certificate_free_credentials(shared->creds);
- free(shared->CAfile);
- free(shared);
+ curlx_free(shared->CAfile);
+ curlx_free(shared);
}
}
}
return;
if(conn_config->CAfile) {
- sc->CAfile = strdup(conn_config->CAfile);
+ sc->CAfile = curlx_strdup(conn_config->CAfile);
if(!sc->CAfile)
return;
}
if(!sdata_len) /* gnutls does this for some version combinations */
return CURLE_OK;
- sdata = malloc(sdata_len); /* get a buffer for it */
+ sdata = curlx_malloc(sdata_len); /* get a buffer for it */
if(!sdata)
return CURLE_OUT_OF_MEMORY;
if(quic_tp && quic_tp_len) {
qtp_clone = Curl_memdup0((char *)quic_tp, quic_tp_len);
if(!qtp_clone) {
- free(sdata);
+ curlx_free(sdata);
return CURLE_OUT_OF_MEMORY;
}
}
if(ret != GNUTLS_E_SHORT_MEMORY_BUFFER || len1 == 0)
break; /* failed */
- buff1 = malloc(len1);
+ buff1 = curlx_malloc(len1);
if(!buff1)
break; /* failed */
#include "hostcheck.h"
#include "../hostip.h"
-#include "../curl_memory.h"
-/* The last #include file should be: */
-#include "../memdebug.h"
-
/* check the two input strings with given length, but do not
assume they end in nul-bytes */
static bool pmatch(const char *hostname, size_t hostlen,
#include "../escape.h"
#include "../curlx/fopen.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* The fp for the open SSLKEYLOGFILE, or NULL if not open */
static FILE *keylog_file_fp;
#include "../strdup.h"
#include "../curl_sha256.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* ALPN for http2 */
#if defined(USE_HTTP2) && defined(MBEDTLS_SSL_ALPN)
# define HAS_ALPN_MBEDTLS
for(i = 0; supported[i] != 0; i++);
supported_len = i;
- selected = malloc(sizeof(int) * (supported_len + 1));
+ selected = curlx_malloc(sizeof(int) * (supported_len + 1));
if(!selected)
return CURLE_OUT_OF_MEMORY;
selected[count] = 0;
if(count == 0) {
- free(selected);
+ curlx_free(selected);
failf(data, "mbedTLS: no supported cipher in list");
return CURLE_SSL_CIPHER;
}
(void)data, (void)crt;
#else
const size_t bufsize = 16384;
- char *p, *buffer = malloc(bufsize);
+ char *p, *buffer = curlx_malloc(bufsize);
if(buffer && mbedtls_x509_crt_info(buffer, bufsize, " ", crt) > 0) {
infof(data, "Server certificate:");
else
infof(data, "Unable to dump certificate information");
- free(buffer);
+ curlx_free(buffer);
#endif
}
return CURLE_OUT_OF_MEMORY;
ret = mbedtls_x509_crt_parse(&backend->cacert, newblob,
ca_info_blob->len + 1);
- free(newblob);
+ curlx_free(newblob);
if(ret < 0) {
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
failf(data, "Error importing ca cert blob - mbedTLS: (-0x%04X) %s",
return CURLE_OUT_OF_MEMORY;
ret = mbedtls_x509_crt_parse(&backend->clicert, newblob,
ssl_cert_blob->len + 1);
- free(newblob);
+ curlx_free(newblob);
if(ret) {
mbedtls_strerror(ret, errorbuf, sizeof(errorbuf));
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
}
- p = calloc(1, sizeof(*p));
+ p = curlx_calloc(1, sizeof(*p));
if(!p)
return CURLE_OUT_OF_MEMORY;
- pubkey = malloc(PUB_DER_MAX_BYTES);
+ pubkey = curlx_malloc(PUB_DER_MAX_BYTES);
if(!pubkey) {
result = CURLE_OUT_OF_MEMORY;
&pubkey[PUB_DER_MAX_BYTES - size], size);
pinnedpubkey_error:
mbedtls_x509_crt_free(p);
- free(p);
- free(pubkey);
+ curlx_free(p);
+ curlx_free(pubkey);
if(result)
return result;
}
goto out;
}
- sdata = malloc(slen);
+ sdata = curlx_malloc(slen);
if(!sdata) {
result = CURLE_OUT_OF_MEMORY;
goto out;
out:
if(msession_alloced)
mbedtls_ssl_session_free(&session);
- free(sdata);
+ curlx_free(sdata);
return result;
}
#include "mbedtls_threadlock.h"
-/* The last 2 #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* number of thread locks */
#define NUMT 2
#include "../curlx/warnless.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#if defined(USE_OPENSSL_ENGINE) || defined(OPENSSL_HAS_PROVIDERS)
#include <openssl/ui.h>
#endif
if(!libctx)
return CURLE_OUT_OF_MEMORY;
if(propq) {
- data->state.propq = strdup(propq);
+ data->state.propq = curlx_strdup(propq);
if(!data->state.propq) {
OSSL_LIB_CTX_free(libctx);
return CURLE_OUT_OF_MEMORY;
goto out;
}
- der_session_buf = der_session_ptr = malloc(der_session_size);
+ der_session_buf = der_session_ptr = curlx_malloc(der_session_size);
if(!der_session_buf) {
result = CURLE_OUT_OF_MEMORY;
goto out;
}
out:
- free(der_session_buf);
+ curlx_free(der_session_buf);
return result;
}
*/
if(CertGetEnhancedKeyUsage(pContext, 0, NULL, &req_size)) {
if(req_size && req_size > enhkey_usage_size) {
- void *tmp = realloc(enhkey_usage, req_size);
+ void *tmp = curlx_realloc(enhkey_usage, req_size);
if(!tmp) {
failf(data, "SSL: Out of memory allocating for OID list");
X509_free(x509);
}
- free(enhkey_usage);
+ curlx_free(enhkey_usage);
CertFreeCertificateContext(pContext);
CertCloseStore(hStore, 0);
if(share->store) {
X509_STORE_free(share->store);
}
- free(share->CAfile);
- free(share);
+ curlx_free(share->CAfile);
+ curlx_free(share);
}
static bool
sizeof(MPROTO_OSSL_X509_KEY)-1);
if(!share) {
- share = calloc(1, sizeof(*share));
+ share = curlx_calloc(1, sizeof(*share));
if(!share)
return;
if(!Curl_hash_add2(&multi->proto_hash,
CURL_UNCONST(MPROTO_OSSL_X509_KEY),
sizeof(MPROTO_OSSL_X509_KEY)-1,
share, oss_x509_share_free)) {
- free(share);
+ curlx_free(share);
return;
}
}
char *CAfile = NULL;
if(conn_config->CAfile) {
- CAfile = strdup(conn_config->CAfile);
+ CAfile = curlx_strdup(conn_config->CAfile);
if(!CAfile) {
X509_STORE_free(store);
return;
if(share->store) {
X509_STORE_free(share->store);
- free(share->CAfile);
+ curlx_free(share->CAfile);
}
share->time = curlx_now();
ech_config_len) != 1) {
infof(data, "ECH: SSL_ECH_set1_ech_config_list failed");
if(data->set.tls_ech & CURLECH_HARD) {
- free(ech_config);
+ curlx_free(ech_config);
return CURLE_SSL_CONNECT_ERROR;
}
}
- free(ech_config);
+ curlx_free(ech_config);
trying_ech_now = 1;
# else
ech_config = (unsigned char *) data->set.str[STRING_ECH_CONFIG];
result = curlx_base64_encode(rcs, rcl, &b64str, &blen);
if(!result && b64str) {
infof(data, "ECH: retry_configs %s", b64str);
- free(b64str);
+ curlx_free(b64str);
#ifndef HAVE_BORINGSSL_LIKE
rv = SSL_ech_get1_status(ssl, &inner, &outer);
infof(data, "ECH: retry_configs for %s from %s, %d %d",
if(len1 < 1)
break; /* failed */
- buff1 = temp = malloc(len1);
+ buff1 = temp = curlx_malloc(len1);
if(!buff1)
break; /* failed */
} while(0);
if(buff1)
- free(buff1);
+ curlx_free(buff1);
return result;
}
#include "cipher_suite.h"
#include "x509asn1.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
struct rustls_ssl_backend_data
{
const struct rustls_client_config *config;
}
#endif /* USE_ECH */
- cipher_suites = malloc(sizeof(*cipher_suites) * (cipher_suites_len));
+ cipher_suites = curlx_malloc(sizeof(*cipher_suites) * (cipher_suites_len));
if(!cipher_suites) {
result = CURLE_OUT_OF_MEMORY;
goto cleanup;
cleanup:
if(cipher_suites) {
- free(cipher_suites);
+ curlx_free(cipher_suites);
}
if(custom_provider_builder) {
rustls_crypto_provider_builder_free(custom_provider_builder);
cleanup:
/* if we base64 decoded, we can free now */
if(data->set.tls_ech & CURLECH_CLA_CFG && data->set.str[STRING_ECH_CONFIG]) {
- free(ech_config);
+ curlx_free(ech_config);
}
if(dns) {
Curl_resolv_unlink(data, &dns);
#include "../progress.h"
#include "../curl_sha256.h"
-/* The last #include file should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/* Some verbose debug messages are wrapped by SCH_DEV() instead of DEBUGF()
* and only shown if CURL_SCHANNEL_DEV_DEBUG was defined at build time. These
* messages are extra verbose and intended for curl developers debugging
return CURLE_SSL_CERTPROBLEM;
*sep = TEXT('\0');
- *store_path = Curl_tcsdup(store_path_start);
+ *store_path = curlx_tcsdup(store_path_start);
*sep = TEXT('\\');
if(!*store_path)
return CURLE_OUT_OF_MEMORY;
failf(data, "schannel: certificate format compatibility error "
" for %s",
blob ? "(memory blob)" : data->set.ssl.primary.clientcert);
- free(cert_store_path);
+ curlx_free(cert_store_path);
curlx_unicodefree(cert_path);
if(fInCert)
curlx_fclose(fInCert);
int cert_find_flags;
const char *cert_showfilename_error = blob ?
"(memory blob)" : data->set.ssl.primary.clientcert;
- free(cert_store_path);
+ curlx_free(cert_store_path);
curlx_unicodefree(cert_path);
if(fInCert) {
long cert_tell = 0;
if(continue_reading)
continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
if(continue_reading)
- certdata = malloc(certsize + 1);
+ certdata = curlx_malloc(certsize + 1);
if((!certdata) ||
((int) fread(certdata, certsize, 1, fInCert) != 1))
continue_reading = FALSE;
if(!continue_reading) {
failf(data, "schannel: Failed to read cert file %s",
data->set.ssl.primary.clientcert);
- free(certdata);
+ curlx_free(certdata);
return CURLE_SSL_CERTPROBLEM;
}
}
if(data->set.ssl.key_passwd)
pwd_len = strlen(data->set.ssl.key_passwd);
- pszPassword = (WCHAR*)malloc(sizeof(WCHAR)*(pwd_len + 1));
+ pszPassword = (WCHAR*)curlx_malloc(sizeof(WCHAR)*(pwd_len + 1));
if(pszPassword) {
if(pwd_len > 0)
str_w_len = MultiByteToWideChar(CP_UTF8,
else
cert_store = PFXImportCertStore(&datablob, pszPassword, 0);
- free(pszPassword);
+ curlx_free(pszPassword);
}
if(!blob)
- free(certdata);
+ curlx_free(certdata);
if(!cert_store) {
DWORD errorcode = GetLastError();
if(errorcode == ERROR_INVALID_PASSWORD)
cert_store_name,
(path_utf8 ? path_utf8 : "(unknown)"),
GetLastError());
- free(cert_store_path);
+ curlx_free(cert_store_path);
curlx_unicodefree(path_utf8);
curlx_unicodefree(cert_path);
return CURLE_SSL_CERTPROBLEM;
}
- free(cert_store_path);
+ curlx_free(cert_store_path);
cert_thumbprint.pbData = cert_thumbprint_data;
cert_thumbprint.cbData = CERT_THUMBPRINT_DATA_LEN;
/* allocate memory for the reusable credential handle */
backend->cred = (struct Curl_schannel_cred *)
- calloc(1, sizeof(struct Curl_schannel_cred));
+ curlx_calloc(1, sizeof(struct Curl_schannel_cred));
if(!backend->cred) {
failf(data, "schannel: unable to allocate memory");
/* allocate memory for the security context handle */
backend->ctxt = (struct Curl_schannel_ctxt *)
- calloc(1, sizeof(struct Curl_schannel_ctxt));
+ curlx_calloc(1, sizeof(struct Curl_schannel_ctxt));
if(!backend->ctxt) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
if(!backend->decdata_buffer) {
backend->decdata_offset = 0;
backend->decdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
- backend->decdata_buffer = malloc(backend->decdata_length);
+ backend->decdata_buffer = curlx_malloc(backend->decdata_length);
if(!backend->decdata_buffer) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
backend->encdata_is_incomplete = FALSE;
backend->encdata_offset = 0;
backend->encdata_length = CURL_SCHANNEL_BUFFER_INIT_SIZE;
- backend->encdata_buffer = malloc(backend->encdata_length);
+ backend->encdata_buffer = curlx_malloc(backend->encdata_length);
if(!backend->encdata_buffer) {
failf(data, "schannel: unable to allocate memory");
return CURLE_OUT_OF_MEMORY;
/* increase internal encrypted data buffer */
size_t reallocated_length = backend->encdata_offset +
CURL_SCHANNEL_BUFFER_FREE_SIZE;
- reallocated_buffer = realloc(backend->encdata_buffer,
- reallocated_length);
+ reallocated_buffer = curlx_realloc(backend->encdata_buffer,
+ reallocated_length);
if(!reallocated_buffer) {
failf(data, "schannel: unable to re-allocate memory");
backend->encdata_offset, backend->encdata_length));
/* setup input buffers */
- InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN, malloc(backend->encdata_offset),
+ InitSecBuffer(&inbuf[0], SECBUFFER_TOKEN,
+ curlx_malloc(backend->encdata_offset),
curlx_uztoul(backend->encdata_offset));
InitSecBuffer(&inbuf[1], SECBUFFER_EMPTY, NULL, 0);
InitSecBufferDesc(&inbuf_desc, inbuf, 2);
if(!SOCKET_WRITABLE(Curl_conn_cf_get_socket(cf, data), 0)) {
SCH_DEV(infof(data, "schannel: handshake waiting for writeable socket"));
connssl->io_need = CURL_SSL_IO_NEED_SEND;
- free(inbuf[0].pvBuffer);
+ curlx_free(inbuf[0].pvBuffer);
return CURLE_OK;
}
/* calculate the complete message length and allocate a buffer for it */
data_len = backend->stream_sizes.cbHeader + len +
backend->stream_sizes.cbTrailer;
- ptr = (unsigned char *)malloc(data_len);
+ ptr = (unsigned char *)curlx_malloc(data_len);
if(!ptr) {
return CURLE_OUT_OF_MEMORY;
}
if(reallocated_length < min_encdata_length) {
reallocated_length = min_encdata_length;
}
- reallocated_buffer = realloc(backend->encdata_buffer,
- reallocated_length);
+ reallocated_buffer = curlx_realloc(backend->encdata_buffer,
+ reallocated_length);
if(!reallocated_buffer) {
result = CURLE_OUT_OF_MEMORY;
failf(data, "schannel: unable to re-allocate memory");
if(reallocated_length < len) {
reallocated_length = len;
}
- reallocated_buffer = realloc(backend->decdata_buffer,
- reallocated_length);
+ reallocated_buffer = curlx_realloc(backend->decdata_buffer,
+ reallocated_length);
if(!reallocated_buffer) {
result = CURLE_OUT_OF_MEMORY;
failf(data, "schannel: unable to re-allocate memory");
if(share->cert_store) {
CertCloseStore(share->cert_store, 0);
}
- free(share->CAfile);
- free(share);
+ curlx_free(share->CAfile);
+ curlx_free(share);
}
bool Curl_schannel_set_cached_cert_store(struct Curl_cfilter *cf,
CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY),
sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1);
if(!share) {
- share = calloc(1, sizeof(*share));
+ share = curlx_calloc(1, sizeof(*share));
if(!share) {
return FALSE;
}
CURL_UNCONST(MPROTO_SCHANNEL_CERT_SHARE_KEY),
sizeof(MPROTO_SCHANNEL_CERT_SHARE_KEY)-1,
share, schannel_cert_share_free)) {
- free(share);
+ curlx_free(share);
return FALSE;
}
}
}
else {
if(conn_config->CAfile) {
- CAfile = strdup(conn_config->CAfile);
+ CAfile = curlx_strdup(conn_config->CAfile);
if(!CAfile) {
return FALSE;
}
if(share->cert_store) {
CertCloseStore(share->cert_store, 0);
}
- free(share->CAfile);
+ curlx_free(share->CAfile);
share->time = curlx_now();
share->cert_store = cert_store;
#include "hostcheck.h"
#include "../curlx/version_win32.h"
-/* The last #include file should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#define BACKEND ((struct schannel_ssl_backend_data *)connssl->backend)
#define MAX_CAFILE_SIZE 1048576 /* 1 MiB */
}
ca_file_bufsize = (size_t)file_size.QuadPart;
- ca_file_buffer = (char *)malloc(ca_file_bufsize + 1);
+ ca_file_buffer = (char *)curlx_malloc(ca_file_bufsize + 1);
if(!ca_file_buffer) {
result = CURLE_OUT_OF_MEMORY;
goto cleanup;
/* CertGetNameString guarantees that the returned name will not contain
* embedded null bytes. This appears to be undocumented behavior.
*/
- cert_hostname_buff = (LPTSTR)malloc(len * sizeof(TCHAR));
+ cert_hostname_buff = (LPTSTR)curlx_malloc(len * sizeof(TCHAR));
if(!cert_hostname_buff) {
result = CURLE_OUT_OF_MEMORY;
goto cleanup;
#include <Security/Security.h>
#endif
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#define CLONE_STRING(var) \
do { \
if(source->var) { \
- dest->var = strdup(source->var); \
+ dest->var = curlx_strdup(source->var); \
if(!dest->var) \
return FALSE; \
} \
if(src) {
/* only if there is data to dupe! */
struct curl_blob *d;
- d = malloc(sizeof(struct curl_blob) + src->len);
+ d = curlx_malloc(sizeof(struct curl_blob) + src->len);
if(!d)
return CURLE_OUT_OF_MEMORY;
d->len = src->len;
struct ssl_connect_data *ctx;
(void)data;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx)
return NULL;
ctx->ssl_impl = Curl_ssl;
ctx->alpn = alpn;
Curl_bufq_init2(&ctx->earlydata, CURL_SSL_EARLY_MAX, 1, BUFQ_OPT_NO_SPARES);
- ctx->backend = calloc(1, ctx->ssl_impl->sizeof_ssl_backend_data);
+ ctx->backend = curlx_calloc(1, ctx->ssl_impl->sizeof_ssl_backend_data);
if(!ctx->backend) {
- free(ctx);
+ curlx_free(ctx);
return NULL;
}
return ctx;
if(ctx) {
Curl_safefree(ctx->negotiated.alpn);
Curl_bufq_free(&ctx->earlydata);
- free(ctx->backend);
- free(ctx);
+ curlx_free(ctx->backend);
+ curlx_free(ctx);
}
}
ci->certinfo[i] = NULL;
}
- free(ci->certinfo); /* free the actual array too */
+ curlx_free(ci->certinfo); /* free the actual array too */
ci->certinfo = NULL;
ci->num_of_certs = 0;
}
Curl_ssl_free_certinfo(data);
/* Allocate the required certificate information structures */
- table = calloc((size_t) num, sizeof(struct curl_slist *));
+ table = curlx_calloc((size_t) num, sizeof(struct curl_slist *));
if(!table)
return CURLE_OUT_OF_MEMORY;
}
/* compute sha256sum of public key */
- sha256sumdigest = malloc(CURL_SHA256_DIGEST_LENGTH);
+ sha256sumdigest = curlx_malloc(CURL_SHA256_DIGEST_LENGTH);
if(!sha256sumdigest)
return CURLE_OUT_OF_MEMORY;
encode = Curl_ssl->sha256sum(pubkey, pubkeylen,
for(i = 0; available_backends[i]; i++) {
if(curl_strequal(env, available_backends[i]->info.name)) {
Curl_ssl = available_backends[i];
- free(env);
+ curlx_free(env);
return 0;
}
}
if(curl_strequal(CURL_DEFAULT_SSL_BACKEND,
available_backends[i]->info.name)) {
Curl_ssl = available_backends[i];
- free(env);
+ curlx_free(env);
return 0;
}
}
/* Fall back to first available backend */
Curl_ssl = available_backends[0];
- free(env);
+ curlx_free(env);
return 0;
}
{
Curl_safefree(peer->sni);
if(peer->dispname != peer->hostname)
- free(peer->dispname);
+ curlx_free(peer->dispname);
peer->dispname = NULL;
Curl_safefree(peer->hostname);
Curl_safefree(peer->scache_key);
goto out;
}
- peer->hostname = strdup(ehostname);
+ peer->hostname = curlx_strdup(ehostname);
if(!peer->hostname)
goto out;
if(!edispname || !strcmp(ehostname, edispname))
peer->dispname = peer->hostname;
else {
- peer->dispname = strdup(edispname);
+ peer->dispname = curlx_strdup(edispname);
if(!peer->dispname)
goto out;
}
if(len && (peer->hostname[len-1] == '.'))
len--;
if(len < USHRT_MAX) {
- peer->sni = calloc(1, len + 1);
+ peer->sni = curlx_calloc(1, len + 1);
if(!peer->sni)
goto out;
Curl_strntolower(peer->sni, peer->hostname, len);
#include "../rand.h"
#include "../curlx/warnless.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
static bool cf_ssl_peer_key_is_global(const char *peer_key);
{
struct Curl_ssl_session *s = obj;
(void)udata;
- free(CURL_UNCONST(s->sdata));
- free(CURL_UNCONST(s->quic_tp));
- free((void *)s->alpn);
- free(s);
+ curlx_free(CURL_UNCONST(s->sdata));
+ curlx_free(CURL_UNCONST(s->quic_tp));
+ curlx_free((void *)s->alpn);
+ curlx_free(s);
}
CURLcode
struct Curl_ssl_session *s;
if(!sdata || !sdata_len) {
- free(sdata);
+ curlx_free(sdata);
return CURLE_BAD_FUNCTION_ARGUMENT;
}
*psession = NULL;
- s = calloc(1, sizeof(*s));
+ s = curlx_calloc(1, sizeof(*s));
if(!s) {
- free(sdata);
- free(quic_tp);
+ curlx_free(sdata);
+ curlx_free(quic_tp);
return CURLE_OUT_OF_MEMORY;
}
s->quic_tp = quic_tp;
s->quic_tp_len = quic_tp_len;
if(alpn) {
- s->alpn = strdup(alpn);
+ s->alpn = curlx_strdup(alpn);
if(!s->alpn) {
cf_ssl_scache_session_ldestroy(NULL, s);
return CURLE_OUT_OF_MEMORY;
DEBUGASSERT(!peer->ssl_peer_key);
if(ssl_peer_key) {
- peer->ssl_peer_key = strdup(ssl_peer_key);
+ peer->ssl_peer_key = curlx_strdup(ssl_peer_key);
if(!peer->ssl_peer_key)
goto out;
peer->hmac_set = FALSE;
goto out;
}
if(clientcert) {
- peer->clientcert = strdup(clientcert);
+ peer->clientcert = curlx_strdup(clientcert);
if(!peer->clientcert)
goto out;
}
if(srp_username) {
- peer->srp_username = strdup(srp_username);
+ peer->srp_username = curlx_strdup(srp_username);
if(!peer->srp_username)
goto out;
}
if(srp_password) {
- peer->srp_password = strdup(srp_password);
+ peer->srp_password = curlx_strdup(srp_password);
if(!peer->srp_password)
goto out;
}
size_t i;
*pscache = NULL;
- peers = calloc(max_peers, sizeof(*peers));
+ peers = curlx_calloc(max_peers, sizeof(*peers));
if(!peers)
return CURLE_OUT_OF_MEMORY;
- scache = calloc(1, sizeof(*scache));
+ scache = curlx_calloc(1, sizeof(*scache));
if(!scache) {
- free(peers);
+ curlx_free(peers);
return CURLE_OUT_OF_MEMORY;
}
for(i = 0; i < scache->peer_count; ++i) {
cf_ssl_scache_clear_peer(&scache->peers[i]);
}
- free(scache->peers);
- free(scache);
+ curlx_free(scache->peers);
+ curlx_free(scache);
}
}
char *abspath = realpath(path, NULL);
if(abspath) {
CURLcode r = curlx_dyn_addf(buf, ":%s-%s", name, abspath);
- (free)(abspath); /* allocated by libc, free without memdebug */
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(abspath); /* allocated by libc, free without memdebug */
return r;
}
*is_local = TRUE;
/* remember peer_key for future lookups */
CURL_TRC_SSLS(data, "peer entry %zu key recovered: %s",
i, ssl_peer_key);
- scache->peers[i].ssl_peer_key = strdup(ssl_peer_key);
+ scache->peers[i].ssl_peer_key = curlx_strdup(ssl_peer_key);
if(!scache->peers[i].ssl_peer_key) {
result = CURLE_OUT_OF_MEMORY;
goto out;
#include "vtls_spack.h"
#include "../strdup.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#ifndef UINT16_MAX
#define UINT16_MAX 0xffff
#endif
goto out;
}
- s = calloc(1, sizeof(*s));
+ s = curlx_calloc(1, sizeof(*s));
if(!s) {
r = CURLE_OUT_OF_MEMORY;
goto out;
#include <wolfssl/error-ssl.h>
#include "wolfssl.h"
-/* The last #include files should be: */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
#ifdef HAVE_WOLFSSL_CTX_GENERATEECHCONFIG
#define USE_ECH_WOLFSSL
#endif
result = CURLE_FAILED_INIT;
goto out;
}
- sdata = calloc(1, sdata_len);
+ sdata = curlx_calloc(1, sdata_len);
if(!sdata) {
failf(data, "unable to allocate session buffer of %u bytes", sdata_len);
result = CURLE_OUT_OF_MEMORY;
if(quic_tp && quic_tp_len) {
qtp_clone = Curl_memdup0((char *)quic_tp, quic_tp_len);
if(!qtp_clone) {
- free(sdata);
+ curlx_free(sdata);
return CURLE_OUT_OF_MEMORY;
}
}
}
out:
- free(sdata);
+ curlx_free(sdata);
return result;
}
if(share->store) {
wolfSSL_X509_STORE_free(share->store);
}
- free(share->CAfile);
- free(share);
+ curlx_free(share->CAfile);
+ curlx_free(share);
}
static bool
sizeof(MPROTO_WSSL_X509_KEY)-1);
if(!share) {
- share = calloc(1, sizeof(*share));
+ share = curlx_calloc(1, sizeof(*share));
if(!share)
return;
if(!Curl_hash_add2(&multi->proto_hash,
CURL_UNCONST(MPROTO_WSSL_X509_KEY),
sizeof(MPROTO_WSSL_X509_KEY)-1,
share, wssl_x509_share_free)) {
- free(share);
+ curlx_free(share);
return;
}
}
char *CAfile = NULL;
if(conn_config->CAfile) {
- CAfile = strdup(conn_config->CAfile);
+ CAfile = curlx_strdup(conn_config->CAfile);
if(!CAfile) {
wolfSSL_X509_STORE_free(store);
return;
if(share->store) {
wolfSSL_X509_STORE_free(share->store);
- free(share->CAfile);
+ curlx_free(share->CAfile);
}
share->time = curlx_now();
&b64str, &blen);
if(!result && b64str)
infof(data, "ECH: (not yet) retry_configs %s", b64str);
- free(b64str);
+ curlx_free(b64str);
}
return CURLE_SSL_CONNECT_ERROR;
}
#include "x509asn1.h"
#include "../curlx/dynbuf.h"
-/* The last 2 #include files should be in this order */
-#include "../curl_memory.h"
-#include "../memdebug.h"
-
/*
* Constants.
*/
if(!result)
result = curlx_dyn_add(&out, "-----END CERTIFICATE-----\n");
}
- free(certptr);
+ curlx_free(certptr);
if(!result)
if(data->set.ssl.certinfo)
result = ssl_push_certinfo_dyn(data, certnum, "Cert", &out);
#include "curlx/strparse.h"
#include "curlx/warnless.h"
-/* The last 2 #include files should be in this order */
-#include "curl_memory.h"
-#include "memdebug.h"
-
/***
RFC 6455 Section 5.2
return result;
DEBUGASSERT(randlen < sizeof(keyval));
if(randlen >= sizeof(keyval)) {
- free(randstr);
+ curlx_free(randstr);
return CURLE_FAILED_INIT;
}
strcpy(keyval, randstr);
- free(randstr);
+ curlx_free(randstr);
for(i = 0; !result && (i < CURL_ARRAYSIZE(heads)); i++) {
if(!Curl_checkheaders(data, heads[i].name, strlen(heads[i].name))) {
result = curlx_dyn_addf(req, "%s: %s\r\n", heads[i].name,
(void)klen;
Curl_bufq_free(&ws->recvbuf);
Curl_bufq_free(&ws->sendbuf);
- free(ws);
+ curlx_free(ws);
}
/*
ws = Curl_conn_meta_get(data->conn, CURL_META_PROTO_WS_CONN);
if(!ws) {
size_t chunk_size = WS_CHUNK_SIZE;
- ws = calloc(1, sizeof(*ws));
+ ws = curlx_calloc(1, sizeof(*ws));
if(!ws)
return CURLE_OUT_OF_MEMORY;
#ifdef DEBUGBUILD
SUBDIRS = vms
EXTRA_DIST = README.md \
+ OS400/.checksrc \
OS400/README.OS400 \
OS400/rpg-examples \
OS400/ccsidcurl.c \
--- /dev/null
+# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
+#
+# SPDX-License-Identifier: curl
+
+# Possible not what we want, but cannot test, just silence the warnings
+allowfunc calloc
+allowfunc free
+allowfunc malloc
+allowfunc realloc
"aprintf" => 1,
"atoi" => 1,
"atol" => 1,
+ "calloc" => 1,
"fclose" => 1,
"fdopen" => 1,
"fopen" => 1,
"fprintf" => 1,
+ "free" => 1,
"freeaddrinfo" => 1,
"freopen" => 1,
"getaddrinfo" => 1,
"LoadLibraryExW" => 1,
"LoadLibraryW" => 1,
"localtime" => 1,
+ "malloc" => 1,
"mbstowcs" => 1,
"msnprintf" => 1,
"mvsnprintf" => 1,
"open" => 1,
"printf" => 1,
+ "realloc" => 1,
"recv" => 1,
"send" => 1,
"snprintf" => 1,
"sscanf" => 1,
"stat" => 1,
"strcat" => 1,
+ "strdup" => 1,
"strerror" => 1,
"strncat" => 1,
"strncpy" => 1,
print <<HEAD
#include <zlib.h>
-#include <memdebug.h> /* keep this as LAST include */
static const unsigned char hugehelpgz[] = {
/* This mumbo-jumbo is the huge help text compressed with gzip.
Thanks to this operation, the size of this data shrank from $gzip
static voidpf zalloc_func(voidpf opaque, unsigned int items, unsigned int size)
{
(void)opaque;
- /* not a typo, keep it calloc() */
- return (voidpf) calloc(items, size);
+ /* not a typo, keep it curlx_calloc() */
+ return (voidpf)curlx_calloc(items, size);
}
static void zfree_func(voidpf opaque, voidpf ptr)
{
(void)opaque;
- free(ptr);
+ curlx_free(ptr);
}
#define HEADERLEN 10
if(inflateInit2(&z, -MAX_WBITS) != Z_OK)
return;
- buf = malloc(BUF_SIZE);
+ buf = curlx_malloc(BUF_SIZE);
if(buf) {
while(1) {
z.avail_out = BUF_SIZE;
else
break; /* error */
}
- free(buf);
+ curlx_free(buf);
}
inflateEnd(&z);
}
if(inflateInit2(&z, -MAX_WBITS) != Z_OK)
return;
- buf = malloc(BUF_SIZE);
+ buf = curlx_malloc(BUF_SIZE);
if(buf) {
while(1) {
z.avail_out = BUF_SIZE;
else
break; /* error */
}
- free(buf);
+ curlx_free(buf);
}
inflateEnd(&z);
}
#include "slist_wc.h"
-/* The last #include files should be: */
-#include "memdebug.h"
-
/*
* slist_wc_append() appends a string to the linked list. This function can be
* used as an initialization function as well as an append function.
return NULL;
if(!list) {
- list = malloc(sizeof(struct slist_wc));
+ list = curlx_malloc(sizeof(struct slist_wc));
if(!list) {
curl_slist_free_all(new_item);
return;
curl_slist_free_all(list->first);
- free(list);
+ curlx_free(list);
}
#endif /* CURL_DISABLE_LIBCURL_OPTION */
#endif
#include "terminal.h"
-#include "memdebug.h" /* keep this as LAST include */
#ifdef HAVE_TERMIOS_H
# include <termios.h>
#include "tool_bname.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifndef HAVE_BASENAME
char *tool_basename(char *path)
#include "tool_cb_dbg.h"
#include "tool_util.h"
-#include "memdebug.h" /* keep this as LAST include */
-
static void dump(const char *timebuf, const char *idsbuf, const char *text,
FILE *stream, const unsigned char *ptr, size_t size,
trace tracetype, curl_infotype infotype);
#include "tool_libinfo.h"
#include "tool_strdup.h"
-#include "memdebug.h" /* keep this as LAST include */
-
static char *parse_filename(const char *ptr, size_t len);
#ifdef _WIN32
if(filename) {
if(outs->stream) {
/* indication of problem, get out! */
- free(filename);
+ curlx_free(filename);
return CURL_WRITEFUNC_ERROR;
}
if(per->config->output_dir) {
outs->filename = curl_maprintf("%s/%s", per->config->output_dir,
filename);
- free(filename);
+ curlx_free(filename);
if(!outs->filename)
return CURL_WRITEFUNC_ERROR;
}
if(clone) {
struct curl_slist *old = hdrcbdata->headlist;
hdrcbdata->headlist = curl_slist_append(old, clone);
- free(clone);
+ curlx_free(clone);
if(!hdrcbdata->headlist) {
curl_slist_free_all(old);
return CURL_WRITEFUNC_ERROR;
curl_free(finalurl);
curl_free(scheme);
curl_url_cleanup(u);
- free(copyloc);
+ curlx_free(copyloc);
}
}
#endif
#include "tool_operate.h"
#include "terminal.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#define MAX_BARLENGTH 400
#define MIN_BARLENGTH 20
#include "tool_util.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifndef _WIN32
/* Wait up to a number of milliseconds for socket activity. This function
waits on read activity on a file descriptor that is not a socket which
#include "tool_operate.h"
#include "tool_cb_see.h"
-#include "memdebug.h" /* keep this as LAST include */
-
/*
** callback for CURLOPT_SEEKFUNCTION
**
#include "tool_cb_wrt.h"
#include "tool_operate.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef _WIN32
#define OPENMODE S_IREAD | S_IWRITE
#else
/* grow the buffer if needed */
if(len > global->term.len) {
- wchar_t *buf = (wchar_t *) realloc(global->term.buf,
- len * sizeof(wchar_t));
+ wchar_t *buf = (wchar_t *)curlx_realloc(global->term.buf,
+ len * sizeof(wchar_t));
if(!buf)
return CURL_WRITEFUNC_ERROR;
global->term.len = len;
#include "tool_paramhlp.h"
#include "tool_main.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
static struct GlobalConfig globalconf;
struct GlobalConfig *global;
struct OperationConfig *config_alloc(void)
{
struct OperationConfig *config =
- calloc(1, sizeof(struct OperationConfig));
+ curlx_calloc(1, sizeof(struct OperationConfig));
if(!config)
return NULL;
struct OperationConfig *prev = last->prev;
free_config_fields(last);
- free(last);
+ curlx_free(last);
last = prev;
}
if(result) {
errorf("error retrieving curl library information");
- free(global->first);
+ curlx_free(global->first);
}
}
else {
errorf("error initializing curl library");
- free(global->first);
+ curlx_free(global->first);
}
}
else {
tool_safefree(global->ssl_sessions);
tool_safefree(global->libcurl);
#ifdef _WIN32
- free(global->term.buf);
+ curlx_free(global->term.buf);
#endif
}
#define checkprefix(a,b) curl_strnequal(b, STRCONST(a))
#define tool_safefree(ptr) \
- do { free((ptr)); (ptr) = NULL;} while(0)
+ do { curlx_free((ptr)); (ptr) = NULL;} while(0)
extern struct GlobalConfig *global;
#include "tool_dirhie.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#if defined(_WIN32) || (defined(MSDOS) && !defined(__DJGPP__))
# define mkdir(x,y) (mkdir)((x))
# ifndef F_OK
#include "tool_doswin.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef _WIN32
# undef PATH_MAX
# define PATH_MAX MAX_PATH
if(len > max_sanitized_len)
return SANITIZE_ERR_INVALID_PATH;
- target = strdup(file_name);
+ target = curlx_strdup(file_name);
if(!target)
return SANITIZE_ERR_OUT_OF_MEMORY;
#ifdef MSDOS
sc = msdosify(&p, target, flags);
- free(target);
+ curlx_free(target);
if(sc)
return sc;
target = p;
len = strlen(target);
if(len > max_sanitized_len) {
- free(target);
+ curlx_free(target);
return SANITIZE_ERR_INVALID_PATH;
}
#endif
if(!(flags & SANITIZE_ALLOW_RESERVED)) {
sc = rename_if_reserved_dos(&p, target, flags);
- free(target);
+ curlx_free(target);
if(sc)
return sc;
target = p;
len = strlen(target);
if(len > max_sanitized_len) {
- free(target);
+ curlx_free(target);
return SANITIZE_ERR_INVALID_PATH;
}
}
return SANITIZE_ERR_INVALID_PATH;
}
- *sanitized = strdup(dos_name);
+ *sanitized = curlx_strdup(dos_name);
return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY;
}
#endif /* MSDOS */
#ifndef MSDOS
if((flags & SANITIZE_ALLOW_PATH) &&
file_name[0] == '\\' && file_name[1] == '\\') {
- *sanitized = strdup(file_name);
+ *sanitized = curlx_strdup(file_name);
if(!*sanitized)
return SANITIZE_ERR_OUT_OF_MEMORY;
return SANITIZE_ERR_OK;
}
#endif
- *sanitized = strdup(fname);
+ *sanitized = curlx_strdup(fname);
return *sanitized ? SANITIZE_ERR_OK : SANITIZE_ERR_OUT_OF_MEMORY;
}
char *mstr = curlx_convert_tchar_to_UTF8(buf);
tool_safefree(config->cacert);
if(mstr)
- config->cacert = strdup(mstr);
+ config->cacert = curlx_strdup(mstr);
curlx_unicodefree(mstr);
if(!config->cacert)
result = CURLE_OUT_OF_MEMORY;
if(socket_w != CURL_SOCKET_BAD)
sclose(socket_w);
- free(tdata);
+ curlx_free(tdata);
return 0;
}
do {
/* Prepare handles for thread */
- tdata = (struct win_thread_data*)calloc(1, sizeof(struct win_thread_data));
+ tdata = (struct win_thread_data*)
+ curlx_calloc(1, sizeof(struct win_thread_data));
if(!tdata) {
- errorf("calloc() error");
+ errorf("curlx_calloc() error");
break;
}
/* Create the listening socket for the thread. When it starts, it will
if(tdata->socket_l != CURL_SOCKET_BAD)
sclose(tdata->socket_l);
- free(tdata);
+ curlx_free(tdata);
}
return CURL_SOCKET_BAD;
#include "tool_easysrc.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
-
/* global variable definitions, for easy-interface source code generation */
struct slist_wc *easysrc_decl; /* Variable declarations */
#include "tool_findfile.h"
#include "tool_cfgable.h"
-#include "memdebug.h" /* keep this as LAST include */
-
struct finder {
const char *env;
const char *append;
if(c) {
int fd = curlx_open(c, O_RDONLY);
if(fd >= 0) {
- char *path = strdup(c);
+ char *path = curlx_strdup(c);
close(fd);
curl_free(c);
return path;
#include "tool_formparse.h"
#include "tool_parsecfg.h"
-#include "memdebug.h" /* keep this as LAST include */
-
/* tool_mime functions. */
static struct tool_mime *tool_mime_new(struct tool_mime *parent,
toolmimekind kind)
{
- struct tool_mime *m = (struct tool_mime *) calloc(1, sizeof(*m));
+ struct tool_mime *m = (struct tool_mime *)curlx_calloc(1, sizeof(*m));
if(m) {
m->kind = kind;
char *mime_data_copy;
struct tool_mime *m = NULL;
- mime_data_copy = strdup(mime_data);
+ mime_data_copy = curlx_strdup(mime_data);
if(mime_data_copy) {
m = tool_mime_new(parent, TOOLMIME_DATA);
if(!m)
- free(mime_data_copy);
+ curlx_free(mime_data_copy);
else
m->data = mime_data_copy;
}
*errcode = CURLE_OUT_OF_MEMORY;
if(strcmp(filename, "-")) {
/* This is a normal file. */
- char *filedup = strdup(filename);
+ char *filedup = curlx_strdup(filename);
if(filedup) {
m = tool_mime_new(parent, TOOLMIME_FILE);
if(!m)
- free(filedup);
+ curlx_free(filedup);
else {
m->data = filedup;
if(!isremotefile)
default:
if(!stdinsize) {
/* Zero-length data has been freed. Re-create it. */
- data = strdup("");
+ data = curlx_strdup("");
if(!data)
return m;
}
tool_safefree(mime->encoder);
tool_safefree(mime->data);
curl_slist_free_all(mime->headers);
- free(mime);
+ curlx_free(mime);
}
}
#define SET_TOOL_MIME_PTR(m, field) \
do { \
if(field) { \
- (m)->field = strdup(field); \
+ (m)->field = curlx_strdup(field); \
if(!(m)->field) \
goto fail; \
} \
}
/* Make a copy we can overwrite. */
- contents = strdup(input);
+ contents = curlx_strdup(input);
if(!contents)
goto fail;
#include "tool_help.h"
#include "var.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#define ALLOW_BLANK TRUE
#define DENY_BLANK FALSE
static ParameterError getstr(char **str, const char *val, bool allowblank)
{
if(*str) {
- free(*str);
+ curlx_free(*str);
*str = NULL;
}
DEBUGASSERT(val);
if(!allowblank && !val[0])
return PARAM_BLANK_STRING;
- *str = strdup(val);
+ *str = curlx_strdup(val);
if(!*str)
return PARAM_NO_MEM;
size_t len, bool allowblank)
{
if(*str) {
- free(*str);
+ curlx_free(*str);
*str = NULL;
}
DEBUGASSERT(val);
if(!allowblank && !val[0])
return PARAM_BLANK_STRING;
- *str = malloc(len + 1);
+ *str = curlx_malloc(len + 1);
if(!*str)
return PARAM_NO_MEM;
* means no passphrase was given and no characters escaped */
if(curl_strnequal(cert_parameter, "pkcs11:", 7) ||
!strpbrk(cert_parameter, ":\\")) {
- *certname = strdup(cert_parameter);
+ *certname = curlx_strdup(cert_parameter);
if(!*certname)
return PARAM_NO_MEM;
return PARAM_OK;
}
/* deal with escaped chars; find unescaped colon if it exists */
- certname_place = malloc(param_length + 1);
+ certname_place = curlx_malloc(param_length + 1);
if(!certname_place) {
err = PARAM_NO_MEM;
goto done;
* above; if we are still here, this is a separating colon */
param_place++;
if(*param_place) {
- *passphrase = strdup(param_place);
+ *passphrase = curlx_strdup(param_place);
if(!*passphrase)
err = PARAM_NO_MEM;
}
/* nextarg is never NULL here */
err = parse_cert_parameter(nextarg, &certname, &passphrase);
if(!err) {
- free(*file);
+ curlx_free(*file);
*file = certname;
if(passphrase) {
- free(*password);
+ curlx_free(*password);
*password = passphrase;
}
}
if(!postdata) {
/* no data from the file, point to a zero byte string to make this
get sent as a POST anyway */
- postdata = strdup("");
+ postdata = curlx_strdup("");
if(!postdata)
return PARAM_NO_MEM;
size = 0;
if(*nextarg == '+') {
/* use without encoding */
- query = strdup(&nextarg[1]);
+ query = curlx_strdup(&nextarg[1]);
if(!query)
err = PARAM_NO_MEM;
}
if(!err) {
if(config->query) {
CURLcode result = curlx_dyn_addf(&dyn, "%s&%s", config->query, query);
- free(query);
+ curlx_free(query);
if(result)
err = PARAM_NO_MEM;
else {
- free(config->query);
+ curlx_free(config->query);
config->query = curlx_dyn_ptr(&dyn);
}
}
if(!postdata) {
/* no data from the file, point to a zero byte string to make this
get sent as a POST anyway */
- postdata = strdup("");
+ postdata = curlx_strdup("");
if(!postdata)
return PARAM_NO_MEM;
}
if(err)
return err;
config->ech_config = curl_maprintf("ecl:%s",tmpcfg);
- free(tmpcfg);
+ curlx_free(tmpcfg);
if(!config->ech_config)
return PARAM_NO_MEM;
} /* file done */
"Appending one for you");
curl_msnprintf(buffer, sizeof(buffer), "%" CURL_FORMAT_CURL_OFF_T "-",
value);
- free(config->range);
- config->range = strdup(buffer);
+ curlx_free(config->range);
+ config->range = curlx_strdup(buffer);
if(!config->range)
err = PARAM_NO_MEM;
}
switch(global->verbosity) {
case 0:
global->verbosity = 1;
- free(global->trace_dump);
- global->trace_dump = strdup("%");
+ curlx_free(global->trace_dump);
+ global->trace_dump = curlx_strdup("%");
if(!global->trace_dump)
err = PARAM_NO_MEM;
else {
error:
if(nextalloc)
- free(CURL_UNCONST(nextarg));
+ curlx_free(CURL_UNCONST(nextarg));
return err;
}
#endif
#include "tool_getpass.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef __VMS
/* VMS implementation */
char *getpass_r(const char *prompt, char *buffer, size_t buflen)
#include "tool_cfgable.h"
#include "terminal.h"
-#include "memdebug.h" /* keep this as LAST include */
-
struct category_descriptors {
const char *opt;
const char *desc;
#ifdef CURL_CA_EMBED
++feat_ext_count;
#endif
- feat_ext = malloc(sizeof(*feature_names) * (feat_ext_count + 1));
+ feat_ext = curlx_malloc(sizeof(*feature_names) * (feat_ext_count + 1));
if(feat_ext) {
memcpy((void *)feat_ext, feature_names,
sizeof(*feature_names) * feature_count);
for(builtin = feat_ext; *builtin; ++builtin)
curl_mprintf(" %s", *builtin);
puts(""); /* newline */
- free((void *)feat_ext);
+ curlx_free((void *)feat_ext);
}
}
if(strcmp(CURL_VERSION, curlinfo->version)) {
#include "tool_msgs.h"
#include "tool_getparam.h"
#include "tool_helpers.h"
-#include "memdebug.h" /* keep this as LAST include */
/*
** Helper functions that are used from more than one source file.
#include "tool_cfgable.h"
#include "tool_msgs.h"
#include "tool_ipfs.h"
-#include "memdebug.h" /* keep this as LAST include */
/* input string ends in slash? */
static bool has_trailing_slash(const char *input)
char *gateway_env = getenv("IPFS_GATEWAY");
if(gateway_env)
- return strdup(gateway_env);
+ return curlx_strdup(gateway_env);
/* Try to find the gateway in the IPFS data folder. */
ipfs_path_c = curl_getenv("IPFS_PATH");
if(config->ipfs_gateway) {
if(!curl_url_set(gatewayurl, CURLUPART_URL, config->ipfs_gateway,
CURLU_GUESS_SCHEME)) {
- gateway = strdup(config->ipfs_gateway);
+ gateway = curlx_strdup(config->ipfs_gateway);
if(!gateway) {
result = CURLE_URL_MALFORMAT;
goto clean;
if(curl_url_get(uh, CURLUPART_URL, &cloneurl, CURLU_URLENCODE)) {
goto clean;
}
- /* we need to strdup the URL so that we can call free() on it later */
- *url = strdup(cloneurl);
+ /* we need to strdup the URL so that we can call curlx_free() on it later */
+ *url = curlx_strdup(cloneurl);
curl_free(cloneurl);
if(!*url)
goto clean;
result = CURLE_OK;
clean:
- free(gateway);
+ curlx_free(gateway);
curl_free(gwhost);
curl_free(gwpath);
curl_free(gwquery);
#include "tool_setup.h"
#include "tool_libinfo.h"
-#include "memdebug.h" /* keep this as LAST include */
/* global variable definitions, for libcurl runtime info */
/* global variable declarations, for libcurl runtime info */
-
extern curl_version_info_data *curlinfo;
extern const char * const *built_in_protos;
#include "tool_libinfo.h"
#include "tool_stderr.h"
-/*
- * This is low-level hard-hacking memory leak tracking and similar. Using
- * the library level code from this client-side is ugly, but we do this
- * anyway for convenience.
- */
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef __VMS
/*
* vms_show is a global variable, used in main() as parameter for
curl_free(env);
curl_dbg_memdebug(fname);
/* this weird stuff here is to make curl_free() get called before
- curl_dbg_memdebug() as otherwise memory tracking will log a free()
+ curl_dbg_memdebug() as otherwise memory tracking will log a curlx_free()
without an alloc! */
}
/* if CURL_MEMLIMIT is set, this enables fail-on-alloc-number-N feature */
#include "tool_cb_prg.h"
#include "terminal.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#define WARN_PREFIX "Warning: "
#define NOTE_PREFIX "Note: "
#define ERROR_PREFIX "curl: "
CURL_EXTERN CURLcode curl_easy_perform_ev(CURL *easy);
#endif
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef CURL_CA_EMBED
#ifndef CURL_DECLARED_CURL_CA_EMBED
#define CURL_DECLARED_CURL_CA_EMBED
static CURLcode add_per_transfer(struct per_transfer **per)
{
struct per_transfer *p;
- p = calloc(1, sizeof(struct per_transfer));
+ p = curlx_calloc(1, sizeof(struct per_transfer));
if(!p)
return CURLE_OUT_OF_MEMORY;
if(!transfers)
else
transfersl = p;
- free(per);
+ curlx_free(per);
return n;
}
curl_easy_cleanup(per->curl);
if(outs->alloc_filename)
- free(outs->filename);
- free(per->url);
- free(per->outfile);
- free(per->uploadfile);
+ curlx_free(outs->filename);
+ curlx_free(per->url);
+ curlx_free(per->outfile);
+ curlx_free(per->uploadfile);
curl_slist_free_all(per->hdrcbdata.headlist);
per->hdrcbdata.headlist = NULL;
return result;
/* Check if config->cert is a PKCS#11 URI and set the config->cert_type if
* necessary */
if(config->cert && !config->cert_type && is_pkcs11_uri(config->cert)) {
- config->cert_type = strdup("ENG");
+ config->cert_type = curlx_strdup("ENG");
if(!config->cert_type)
return CURLE_OUT_OF_MEMORY;
}
/* Check if config->key is a PKCS#11 URI and set the config->key_type if
* necessary */
if(config->key && !config->key_type && is_pkcs11_uri(config->key)) {
- config->key_type = strdup("ENG");
+ config->key_type = curlx_strdup("ENG");
if(!config->key_type)
return CURLE_OUT_OF_MEMORY;
}
* config->proxy_type if necessary */
if(config->proxy_cert && !config->proxy_cert_type &&
is_pkcs11_uri(config->proxy_cert)) {
- config->proxy_cert_type = strdup("ENG");
+ config->proxy_cert_type = curlx_strdup("ENG");
if(!config->proxy_cert_type)
return CURLE_OUT_OF_MEMORY;
}
* config->proxy_key_type if necessary */
if(config->proxy_key && !config->proxy_key_type &&
is_pkcs11_uri(config->proxy_key)) {
- config->proxy_key_type = strdup("ENG");
+ config->proxy_key_type = curlx_strdup("ENG");
if(!config->proxy_key_type)
return CURLE_OUT_OF_MEMORY;
}
if(uerr)
result = urlerr_cvt(uerr);
else {
- free(per->url); /* free previous URL */
+ curlx_free(per->url); /* free previous URL */
per->url = updated; /* use our new URL instead! */
}
}
char *d = curl_maprintf("%s/%s", config->output_dir, per->outfile);
if(!d)
return CURLE_WRITE_ERROR;
- free(per->outfile);
+ curlx_free(per->outfile);
per->outfile = d;
}
/* Create the directory hierarchy, if not pre-existent to a multiple
}
per->etag_save = etag_first; /* copy the whole struct */
if(state->uploadfile) {
- per->uploadfile = strdup(state->uploadfile);
+ per->uploadfile = curlx_strdup(state->uploadfile);
if(!per->uploadfile ||
SetHTTPrequest(TOOL_HTTPREQ_PUT, &config->httpreq)) {
tool_safefree(per->uploadfile);
if(glob_inuse(&state->urlglob))
result = glob_next_url(&per->url, &state->urlglob);
else if(!state->urlidx) {
- per->url = strdup(u->url);
+ per->url = curlx_strdup(u->url);
if(!per->url)
result = CURLE_OUT_OF_MEMORY;
}
return result;
if(u->outfile) {
- per->outfile = strdup(u->outfile);
+ per->outfile = curlx_strdup(u->outfile);
if(!per->outfile)
return CURLE_OUT_OF_MEMORY;
}
{
struct contextuv *c;
- c = (struct contextuv *) malloc(sizeof(*c));
+ c = (struct contextuv *)curlx_malloc(sizeof(*c));
c->sockfd = sockfd;
c->uv = uv;
static void close_cb(uv_handle_t *handle)
{
struct contextuv *c = (struct contextuv *) handle->data;
- free(c);
+ curlx_free(c);
}
static void destroy_context(struct contextuv *c)
env = curl_getenv("CURL_CA_BUNDLE");
if(env) {
- config->cacert = strdup(env);
+ config->cacert = curlx_strdup(env);
curl_free(env);
if(!config->cacert) {
result = CURLE_OUT_OF_MEMORY;
else {
env = curl_getenv("SSL_CERT_DIR");
if(env) {
- config->capath = strdup(env);
+ config->capath = curlx_strdup(env);
curl_free(env);
if(!config->capath) {
result = CURLE_OUT_OF_MEMORY;
}
env = curl_getenv("SSL_CERT_FILE");
if(env) {
- config->cacert = strdup(env);
+ config->cacert = curlx_strdup(env);
curl_free(env);
if(!config->cacert) {
result = CURLE_OUT_OF_MEMORY;
FILE *cafile = tool_execpath("curl-ca-bundle.crt", &cacert);
if(cafile) {
curlx_fclose(cafile);
- config->cacert = strdup(cacert);
+ config->cacert = curlx_strdup(cacert);
if(!config->cacert) {
result = CURLE_OUT_OF_MEMORY;
goto fail;
if(found_curlrc) {
/* After parse_args so notef knows the verbosity */
notef("Read config file from '%s'", curlrc_path);
- free(curlrc_path);
+ curlx_free(curlrc_path);
}
if(res) {
result = CURLE_OK;
#include "tool_doswin.h"
#include "tool_operhlp.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
void clean_getout(struct OperationConfig *config)
{
if(!newpath)
goto fail;
uerr = curl_url_set(uh, CURLUPART_PATH, newpath, 0);
- free(newpath);
+ curlx_free(newpath);
if(uerr) {
result = urlerr_cvt(uerr);
goto fail;
result = urlerr_cvt(uerr);
goto fail;
}
- free(*inurlp);
+ curlx_free(*inurlp);
*inurlp = newurl;
result = CURLE_OK;
}
if(pc) {
/* duplicate the string beyond the slash */
- *filename = strdup(pc + 1);
+ *filename = curlx_strdup(pc + 1);
}
else {
/* no slash => empty string, use default */
- *filename = strdup("curl_response");
+ *filename = curlx_strdup("curl_response");
warnf("No remote filename, uses \"%s\"", *filename);
}
#include "tool_util.h"
#include "tool_version.h"
-#include "memdebug.h" /* keep this as LAST include */
-
struct getout *new_getout(struct OperationConfig *config)
{
- struct getout *node = calloc(1, sizeof(struct getout));
+ struct getout *node = curlx_calloc(1, sizeof(struct getout));
struct getout *last = config->url_last;
if(node) {
static int outnum = 0;
curlx_dyn_init(&obuf, MAX_PROTOSTRING);
- protoset = malloc((proto_count + 1) * sizeof(*protoset));
+ protoset = curlx_malloc((proto_count + 1) * sizeof(*protoset));
if(!protoset)
return PARAM_NO_MEM;
for(proto = 0; protoset[proto] && !result; proto++)
result = curlx_dyn_addf(&obuf, "%s%s", curlx_dyn_len(&obuf) ? "," : "",
protoset[proto]);
- free((char *) protoset);
+ curlx_free((char *)protoset);
if(result)
return PARAM_NO_MEM;
if(!curlx_dyn_len(&obuf)) {
curlx_dyn_free(&obuf);
return PARAM_BAD_USE;
}
- free(*ostr);
+ curlx_free(*ostr);
*ostr = curlx_dyn_ptr(&obuf);
return PARAM_OK;
}
return CURLE_OUT_OF_MEMORY;
/* return the new string */
- free(*userpwd);
+ curlx_free(*userpwd);
*userpwd = curlx_dyn_ptr(&dyn);
}
#include "tool_msgs.h"
#include "tool_parsecfg.h"
#include "tool_util.h"
-#include "memdebug.h" /* keep this as LAST include */
/* only acknowledge colon or equals as separators if the option was not
specified with an initial dash! */
if(curlrc) {
file = curlx_fopen(curlrc, FOPEN_READTEXT);
if(!file) {
- free(curlrc);
+ curlx_free(curlrc);
return PARAM_READ_ERROR;
}
filename = pathalloc = curlrc;
errorf("cannot read config from '%s'", filename);
if(!err && resolved) {
- *resolved = strdup(filename);
+ *resolved = curlx_strdup(filename);
if(!*resolved)
err = PARAM_NO_MEM;
}
- free(pathalloc);
+ curlx_free(pathalloc);
return err;
}
#ifndef CURL_DISABLE_LIBCURL_OPTION
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
/* Lookup tables for converting setopt values back to symbols */
/* For enums, values may be in any order. */
ret = easysrc_addf(&easysrc_data,
"slist%d = curl_slist_append(slist%d, \"%s\");",
*slistno, *slistno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
return ret;
easysrc_addf(&easysrc_code,
"curl_mime_data(part%d, \"%s\", CURL_ZERO_TERMINATED);",
mimeno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
break;
ret = easysrc_addf(&easysrc_code,
"curl_mime_filename(part%d, NULL);", mimeno);
}
- free(escaped);
+ curlx_free(escaped);
break;
}
char *escaped = c_escape(part->encoder, ZERO_TERMINATED);
ret = easysrc_addf(&easysrc_code, "curl_mime_encoder(part%d, \"%s\");",
mimeno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
if(!ret && filename) {
char *escaped = c_escape(filename, ZERO_TERMINATED);
ret = easysrc_addf(&easysrc_code, "curl_mime_filename(part%d, \"%s\");",
mimeno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
if(!ret && part->name) {
char *escaped = c_escape(part->name, ZERO_TERMINATED);
ret = easysrc_addf(&easysrc_code, "curl_mime_name(part%d, \"%s\");",
mimeno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
if(!ret && part->type) {
char *escaped = c_escape(part->type, ZERO_TERMINATED);
ret = easysrc_addf(&easysrc_code, "curl_mime_type(part%d, \"%s\");",
mimeno, escaped);
- free(escaped);
+ curlx_free(escaped);
}
if(!ret && part->headers) {
result = easysrc_addf(&easysrc_code,
"curl_easy_setopt(hnd, %s, \"%s\");",
name, escaped);
- free(escaped);
+ curlx_free(escaped);
}
else
result = CURLE_OUT_OF_MEMORY;
#ifndef HAVE_STRDUP
#include "tool_strdup.h"
+#undef Curl_strdup
+#define Curl_strdup tool_strdup
#endif
#ifndef tool_nop_stmt
#include "tool_ssls.h"
#include "tool_parsecfg.h"
-#include "memdebug.h" /* keep this as LAST include */
-
/* The maximum line length for an ecoded session ticket */
#define MAX_SSLS_LINE (64 * 1024)
if(fp)
curlx_fclose(fp);
curlx_dyn_free(&buf);
- free(shmac);
- free(sdata);
+ curlx_free(shmac);
+ curlx_free(sdata);
return r;
}
out:
if(r)
warnf("Warning: error saving SSL session for '%s': %d", session_key, r);
- free(enc);
+ curlx_free(enc);
return r;
}
#include "tool_setup.h"
#include "tool_operate.h"
-
CURLcode tool_ssls_load(struct OperationConfig *config,
CURLSH *share, const char *filename);
CURLcode tool_ssls_save(struct OperationConfig *config,
#include "tool_stderr.h"
#include "tool_msgs.h"
-#include "memdebug.h" /* keep this as LAST include */
-
FILE *tool_stderr;
void tool_init_stderr(void)
*
***************************************************************************/
#include "tool_strdup.h"
-#include "memdebug.h" /* keep this as LAST include */
#ifndef HAVE_STRDUP
-char *strdup(const char *str)
+char *tool_strdup(const char *str)
{
size_t len;
char *newstr;
len = strlen(str) + 1;
- newstr = malloc(len);
+ newstr = curlx_malloc(len);
if(!newstr)
return (char *)NULL;
char *memdup0(const char *data, size_t len)
{
- char *p = malloc(len + 1);
+ char *p = curlx_malloc(len + 1);
if(!p)
return NULL;
if(len)
#include "tool_setup.h"
#ifndef HAVE_STRDUP
-extern char *strdup(const char *str);
+extern char *tool_strdup(const char *str);
#endif
char *memdup0(const char *data, size_t len);
#include "tool_urlglob.h"
#include "tool_vms.h"
#include "tool_strdup.h"
-#include "memdebug.h" /* keep this as LAST include */
static CURLcode globerror(struct URLGlob *glob, const char *err,
size_t pos, CURLcode error)
pat->globindex = -1;
pat->c.set.size = 0;
pat->c.set.idx = 0;
- pat->c.set.elem = malloc(sizeof(char *));
+ pat->c.set.elem = curlx_malloc(sizeof(char *));
if(!pat->c.set.elem)
return globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY);
if(!palloc) {
palloc = 5; /* a reasonable default */
- elem = malloc(palloc * sizeof(char *));
+ elem = curlx_malloc(palloc * sizeof(char *));
}
else if(size >= palloc) {
- char **arr = realloc(elem, palloc * 2 * sizeof(char *));
+ char **arr = curlx_realloc(elem, palloc * 2 * sizeof(char *));
if(!arr) {
result = globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY);
goto error;
goto error;
}
- elem[size] =
- strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : "");
+ elem[size] = curlx_strdup(curlx_dyn_ptr(&glob->buf) ?
+ curlx_dyn_ptr(&glob->buf) : "");
if(!elem[size]) {
result = globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY);
goto error;
for(i = 0; i < size; i++)
tool_safefree(elem[i]);
}
- free(elem);
+ curlx_free(elem);
return result;
}
struct URLPattern *np = NULL;
glob->palloc *= 2;
if(glob->pnum < 255) { /* avoid ridiculous amounts */
- np = realloc(glob->pattern, glob->palloc * sizeof(struct URLPattern));
+ np = curlx_realloc(glob->pattern,
+ glob->palloc * sizeof(struct URLPattern));
if(!np)
return globerror(glob, NULL, pos, CURLE_OUT_OF_MEMORY);
}
memset(glob, 0, sizeof(struct URLGlob));
curlx_dyn_init(&glob->buf, 1024*1024);
- glob->pattern = malloc(2 * sizeof(struct URLPattern));
+ glob->pattern = curlx_malloc(2 * sizeof(struct URLPattern));
if(!glob->pattern)
return CURLE_OUT_OF_MEMORY;
glob->palloc = 2;
}
*globbed =
- strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : "");
+ curlx_strdup(curlx_dyn_ptr(&glob->buf) ? curlx_dyn_ptr(&glob->buf) : "");
if(!*globbed)
return CURLE_OUT_OF_MEMORY;
#include "tool_setup.h"
#include "tool_util.h"
-#include "memdebug.h" /* keep this as LAST include */
#ifdef _WIN32
#include "curlmsg_vms.h"
#include "tool_vms.h"
-#include "memdebug.h" /* keep this as LAST include */
void decc$__posix_exit(int __status);
void decc$exit(int __status);
#include "tool_cfgable.h"
#include "tool_writeout.h"
#include "tool_writeout_json.h"
-#include "memdebug.h" /* keep this as LAST include */
static int writeTime(FILE *stream, const struct writeoutvar *wovar,
struct per_transfer *per, CURLcode per_result,
#include "tool_setup.h"
#include "tool_xattr.h"
-#include "memdebug.h" /* keep this as LAST include */
-
#ifdef USE_XATTR
/* mapping table of curl metadata to extended attribute names */
#include "tool_writeout_json.h"
#include "tool_strdup.h"
#include "var.h"
-#include "memdebug.h" /* keep this as LAST include */
#define MAX_EXPAND_CONTENT 10000000
#define MAX_VAR_LEN 128 /* max length of a name */
while(list) {
struct tool_var *t = list;
list = list->next;
- free(CURL_UNCONST(t->content));
- free(t);
+ curlx_free(CURL_UNCONST(t->content));
+ curlx_free(t);
}
}
break;
}
if(alloc)
- free(c);
+ curlx_free(c);
clen = curlx_dyn_len(out);
c = memdup0(curlx_dyn_ptr(out), clen);
alloc = TRUE;
}
if(alloc)
- free(c);
+ curlx_free(c);
if(err)
curlx_dyn_free(out);
return err;
if(check)
notef("Overwriting variable '%s'", check->name);
- p = calloc(1, sizeof(struct tool_var) + nlen);
+ p = curlx_calloc(1, sizeof(struct tool_var) + nlen);
if(p) {
memcpy(p->name, name, nlen);
/* the null termination byte is already present from above */
global->variables = p;
return PARAM_OK;
}
- free(p);
+ curlx_free(p);
}
return PARAM_NO_MEM;
}
err = addvariable(name, nlen, content, clen, contalloc);
if(err) {
if(contalloc)
- free(content);
+ curlx_free(content);
}
return err;
}
# scripts used in test cases
TESTSCRIPTS = \
test1119.pl \
- test1132.pl \
test1135.pl \
test1139.pl \
test1140.pl \
test1101 test1102 test1103 test1104 test1105 test1106 test1107 test1108 \
test1109 test1110 test1111 test1112 test1113 test1114 test1115 test1116 \
test1117 test1118 test1119 test1120 test1121 test1122 test1123 test1124 \
-test1125 test1126 test1127 test1128 test1129 test1130 test1131 test1132 \
+test1125 test1126 test1127 test1128 test1129 test1130 test1131 \
test1133 test1134 test1135 test1136 test1137 test1138 test1139 test1140 \
test1141 test1142 test1143 test1144 test1145 test1146 test1147 test1148 \
test1149 test1150 test1151 test1152 test1153 test1154 test1155 test1156 \
+++ /dev/null
-<testcase>
-<info>
-<keywords>
-source analysis
-memory-includes
-</keywords>
-</info>
-
-#
-# Client-side
-<client>
-<name>
-Verify memory #include files in libcurl's C source files
-</name>
-
-<command type="perl">
-%SRCDIR/test1132.pl %SRCDIR/../lib
-</command>
-</client>
-
-</testcase>
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static void usage_h2_pausing(const char *msg)
{
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static FILE *out_download = NULL;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static size_t write_h2_upg_extreme_cb(char *ptr, size_t size, size_t nmemb,
void *opaque)
#include "testtrace.h"
-#include "curl_mem_undef.h"
-
#if defined(USE_QUICHE) || defined(USE_OPENSSL)
#include <openssl/ssl.h>
#endif
#include <rustls.h>
#endif
-#include "memdebug.h"
-
static int verbose_d = 1;
struct transfer_d {
pause_offset = (size_t)num;
break;
case 'r':
- free(resolve);
- resolve = strdup(coptarg);
+ curlx_free(resolve);
+ resolve = curlx_strdup(coptarg);
break;
case 'T':
if(!curlx_str_number(&opt, &num, LONG_MAX))
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);
- transfer_d = calloc(transfer_count_d, sizeof(*transfer_d));
+ transfer_d = curlx_calloc(transfer_count_d, sizeof(*transfer_d));
if(!transfer_d) {
curl_mfprintf(stderr, "error allocating transfer structs\n");
res = (CURLcode)1;
else /* on success we expect ssl to have been checked */
assert(t->checked_ssl);
}
- free(transfer_d);
+ curlx_free(transfer_d);
}
curl_share_cleanup(share);
optcleanup:
- free(resolve);
+ curlx_free(resolve);
return res;
}
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static int verbose_u = 1;
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);
- transfer_u = calloc(transfer_count_u, sizeof(*transfer_u));
+ transfer_u = curlx_calloc(transfer_count_u, sizeof(*transfer_u));
if(!transfer_u) {
curl_mfprintf(stderr, "error allocating transfer structs\n");
res = (CURLcode)1;
curl_mime_free(t->mime);
}
}
- free(transfer_u);
+ curlx_free(transfer_u);
}
curl_share_cleanup(share);
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static int tse_found_tls_session = FALSE;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static size_t total_read = 0;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
#ifndef CURL_DISABLE_WEBSOCKETS
size_t i, scount = count, rcount = count;
int rblock, sblock;
- send_buf = calloc(1, plen_max + 1);
- recv_buf = calloc(1, plen_max + 1);
+ send_buf = curlx_calloc(1, plen_max + 1);
+ recv_buf = curlx_calloc(1, plen_max + 1);
if(!send_buf || !recv_buf) {
r = CURLE_OUT_OF_MEMORY;
goto out;
ws_close(curl);
curl_easy_cleanup(curl);
}
- free(send_buf);
- free(recv_buf);
+ curlx_free(send_buf);
+ curlx_free(recv_buf);
return r;
}
curl_mfprintf(stderr, "test_ws_data_m1_echo(min=%zu, max=%zu)\n",
plen_min, plen_max);
memset(&m1_ctx, 0, sizeof(m1_ctx));
- m1_ctx.send_buf = calloc(1, plen_max + 1);
- m1_ctx.recv_buf = calloc(1, plen_max + 1);
+ m1_ctx.send_buf = curlx_calloc(1, plen_max + 1);
+ m1_ctx.recv_buf = curlx_calloc(1, plen_max + 1);
if(!m1_ctx.send_buf || !m1_ctx.recv_buf) {
r = CURLE_OUT_OF_MEMORY;
goto out;
if(m1_ctx.curl) {
curl_easy_cleanup(m1_ctx.curl);
}
- free(m1_ctx.send_buf);
- free(m1_ctx.recv_buf);
+ curlx_free(m1_ctx.send_buf);
+ curlx_free(m1_ctx.recv_buf);
return r;
}
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
#ifndef CURL_DISABLE_WEBSOCKETS
#include <locale.h> /* for setlocale() */
#endif
-#include "memdebug.h"
-
int select_wrapper(int nfds, fd_set *rd, fd_set *wr, fd_set *exc,
struct timeval *tv)
{
*/
-#include "memdebug.h"
-
#define F_RESUME (1 << 0) /* resume/range. */
#define F_HTTP416 (1 << 1) /* Server returns http code 416. */
#define F_FAIL (1 << 2) /* Fail on error. */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t1485_transfer_status {
CURL *curl;
curl_off_t out_len;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1500(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1501(const char *URL)
{
static const long HANG_TIMEOUT = 30 * 1000;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1502(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1506(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1507_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
(void)ptr;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1508(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t realHeaderSize = 0;
static size_t WriteOutput(char *ptr, size_t size, size_t nmemb, void *stream)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1510(const char *URL)
{
static const int NUM_URLS = 4;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1511(const char *URL)
{
long unmet;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1512(const char *URL)
{
CURLcode res = CURLE_OK;
#include "first.h"
-#include "memdebug.h"
-
static int progressKiller(void *arg,
double dltotal,
double dlnow,
#include "first.h"
-#include "memdebug.h"
-
struct t1514_WriteThis {
char *readptr;
size_t sizeleft;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
#define DNS_TIMEOUT 1L
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t1517_WriteThis {
const char *readptr;
size_t sizeleft;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test inspired by github issue 3340 */
static size_t t1518_write_cb(char *buffer, size_t size, size_t nitems,
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct upload_status {
int lines_read;
};
/* test case and code based on https://github.com/curl/curl/issues/2847 */
#include "testtrace.h"
-#include "memdebug.h"
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
curlsocktype purpose)
/* test case and code based on https://github.com/curl/curl/issues/3927 */
-#include "memdebug.h"
-
static int dload_progress_cb(void *a, curl_off_t b, curl_off_t c,
curl_off_t d, curl_off_t e)
{
#include "first.h"
-#include "memdebug.h"
-
static const char t1525_testdata[] = "Hello Cloud!\n";
static size_t t1525_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
#include "first.h"
-#include "memdebug.h"
-
static const char t1526_testdata[] = "Hello Cloud!\n";
static size_t t1526_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
#include "first.h"
-#include "memdebug.h"
-
static const char t1527_testdata[] = "Hello Cloud!\n";
static size_t t1527_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1528(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1529(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static curl_socket_t opensocket(void *clientp,
curlsocktype purpose,
struct curl_sockaddr *address)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1531(const char *URL)
{
static char const testData[] = ".abc\0xyz";
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test CURLINFO_RESPONSE_CODE */
static CURLcode test_lib1532(const char *URL)
#include "first.h"
-#include "memdebug.h"
-
struct cb_data {
CURL *curl;
int response_received;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test CURLINFO_FILETIME */
static CURLcode test_lib1534(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test CURLINFO_PROTOCOL */
static CURLcode test_lib1535(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test CURLINFO_SCHEME */
static CURLcode test_lib1536(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1537(const char *URL)
{
const unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1538(const char *URL)
{
CURLcode res = CURLE_OK;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
struct t1540_transfer_status {
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t1541_transfer_status {
CURL *curl;
int hd_count;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static CURLcode test_lib1542(const char *URL)
{
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static CURLcode test_lib1549(const char *URL)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#include <curl/multi.h>
static CURLcode test_lib1550(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#include <curl/multi.h>
static CURLcode test_lib1551(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1552(const char *URL)
{
CURL *curl = NULL;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static int t1553_xferinfo(void *p,
curl_off_t dltotal, curl_off_t dlnow,
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static const char *ldata_names[] = {
"NONE",
"SHARE",
#include "first.h"
-#include "memdebug.h"
-
static CURL *t1555_curl;
static int progressCallback(void *arg,
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct headerinfo {
size_t largest;
};
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1557(const char *URL)
{
CURLM *multi = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1558(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1559(const char *URL)
{
static const int EXCESSIVE = 10*1000*1000;
global_init(CURL_GLOBAL_ALL);
easy_init(curl);
- longurl = malloc(EXCESSIVE);
+ longurl = curlx_malloc(EXCESSIVE);
if(!longurl) {
res = TEST_ERR_MAJOR_BAD;
goto test_cleanup;
}
test_cleanup:
- free(longurl);
+ curlx_free(longurl);
curl_easy_cleanup(curl);
curl_global_cleanup();
#define USE_IDN
#endif
-#include "memdebug.h" /* LAST include file */
-
static int checkparts(CURLU *u, const char *in, const char *wanted,
unsigned int getflags)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#define WAKEUP_NUM 10
static CURLcode test_lib1564(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#include <curl/multi.h>
static CURLcode test_lib1567(const char *URL)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1568(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1569(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1571(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static char t1576_testdata[] = "request indicates that the client, which made";
static size_t t1576_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1582(const char *URL)
{
CURLcode res;
#include "first.h"
-#include "memdebug.h"
-
static size_t consumed = 0;
static size_t t1591_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1593(const char *URL)
{
struct curl_slist *header = NULL;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1594(const char *URL)
{
struct curl_slist *header = NULL;
#include "first.h"
-#include "memdebug.h"
-
struct pair {
const char *in;
CURLcode *exp;
#include "first.h"
-#include "memdebug.h"
-
/*
* carefully not leak memory on OOM
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1900(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1901_read_cb(char *ptr, size_t size, size_t nmemb, void *stream)
{
static const char *chunks[] = {
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1902(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1903(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1905(const char *URL)
{
CURLSH *share = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1906(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1907(const char *URL)
{
char *url_after;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1908(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1910(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* The maximum string length limit (CURL_MAX_INPUT_LENGTH) is an internal
define not publicly exposed so we set our own */
#define MAX_INPUT_LENGTH 8000000
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#define print_err(name, exp) \
curl_mfprintf(stderr, "Type mismatch for CURLOPT_%s (expected %s)\n", \
name, exp)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1913(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
struct state {
int index;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1916(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1918(const char *URL)
{
const struct curl_easyoption *o;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1919(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1933(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1934(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1935(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1936(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1937(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1938(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1939(const char *URL)
{
CURLM *multi;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1940_write_cb(char *data, size_t n, size_t l, void *userp)
{
/* take care of the data here, ignored in this example */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static void t1945_showem(CURL *curl, unsigned int type)
{
struct curl_header *header = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1947_write_cb(char *data, size_t n, size_t l, void *userp)
{
/* ignore the data */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1955(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1956(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1957(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1958(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1959(const char *URL)
{
CURL *curl;
#include <arpa/inet.h>
#endif
-#include "memdebug.h"
-
/* to prevent libcurl from closing our socket */
static int closesocket_cb(void *clientp, curl_socket_t item)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1964(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1970(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1971_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
{
(void)ptr;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1972(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1973(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1974(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t1975_read_cb(char *ptr, size_t size, size_t nitems, void *userp)
{
(void)ptr;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1977(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib1978(const char *URL)
{
CURL *curl;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode send_request(CURL *curl, const char *url, int seq,
long auth_scheme, const char *userpwd)
{
CURLcode res;
size_t len = strlen(url) + 4 + 1;
- char *full_url = malloc(len);
+ char *full_url = curlx_malloc(len);
if(!full_url) {
curl_mfprintf(stderr, "Not enough memory for full url\n");
return CURLE_OUT_OF_MEMORY;
res = curl_easy_perform(curl);
test_cleanup:
- free(full_url);
+ curlx_free(full_url);
return res;
}
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#define MAX_EASY_HANDLES 3
static int ntlm_counter[MAX_EASY_HANDLES];
int num_handles = 0;
enum HandleState state = ReadyForNewHandle;
size_t urllen = strlen(URL) + 4 + 1;
- char *full_url = malloc(urllen);
+ char *full_url = curlx_malloc(urllen);
start_test_timing();
res_global_init(CURL_GLOBAL_ALL);
if(res) {
- free(full_url);
+ curlx_free(full_url);
return res;
}
curl_multi_cleanup(multi);
curl_global_cleanup();
- free(full_url);
+ curlx_free(full_url);
return res;
}
global_init(CURL_GLOBAL_ALL);
memset(&ws_data, 0, sizeof(ws_data));
- ws_data.buf = (char *)calloc(LIB2302_BUFSIZE, 1);
+ ws_data.buf = (char *)curlx_calloc(LIB2302_BUFSIZE, 1);
if(ws_data.buf) {
curl = curl_easy_init();
if(curl) {
curl_easy_cleanup(curl);
flush_data(&ws_data);
}
- free(ws_data.buf);
+ curlx_free(ws_data.buf);
}
curl_global_cleanup();
return res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib2402(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib2404(const char *URL)
{
CURLcode res = CURLE_OK;
#include "first.h"
-#include "memdebug.h"
-
/* ---------------------------------------------------------------- */
#define test_check(expected_fds) \
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static CURLcode test_lib2502(const char *URL)
{
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
#ifndef CURL_DISABLE_WEBSOCKETS
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3010(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3025(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3027(const char *URL)
{
CURLcode ret = CURLE_OK;
#include "testtrace.h"
-#include "memdebug.h"
-
static CURLcode t3033_req_test(CURLM *multi, CURL *curl,
const char *URL, int index)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3100(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3101(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Verify correct order of certificates in the chain by comparing the
* subject and issuer attributes of each certificate.
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3103(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3104(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3105(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#ifdef USE_THREADS_POSIX
#include <pthread.h>
#endif
/* append the data to contents */
size_t realsize = size * nmemb;
struct Ctx *mem = (struct Ctx *)userp;
- char *data = (char *)malloc(realsize + 1);
+ char *data = (char *)curlx_malloc(realsize + 1);
struct curl_slist *item_append = NULL;
if(!data) {
curl_mprintf("not enough memory (malloc returned NULL)\n");
memcpy(data, contents, realsize);
data[realsize] = '\0';
item_append = curl_slist_append(mem->contents, data);
- free(data);
+ curlx_free(data);
if(item_append) {
mem->contents = item_append;
}
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib3208(const char *URL)
{
CURL *curl = NULL;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static int testcounter;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib501(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Get a single URL without select().
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Source code in here hugely as reported in bug report 651460 by
* Christopher R. Palmer.
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Source code in here hugely as reported in bug report 651464 by
* Christopher R. Palmer.
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* This example shows an FTP upload, with a rename of the file just after
* a successful upload.
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
#define THREADS 2
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib507(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t508_WriteThis {
const char *readptr;
size_t sizeleft;
* libcurl and that it works unconditionally no matter how libcurl is built,
* nothing more.
*
- * Do not include memdebug.h in this source file, and do not use directly
- * memory related functions in this file except those used inside custom
- * memory callbacks which should be calling 'the real thing'.
+ * Do not use directly memory related functions in this file except those used
+ * inside custom memory callbacks which should be calling 'the real thing'.
*/
static int seen;
static void *custom_calloc(size_t nmemb, size_t size)
{
seen++;
- return (calloc)(nmemb, size);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ return calloc(nmemb, size);
}
static void *custom_malloc(size_t size)
{
seen++;
- return (malloc)(size);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ return malloc(size);
}
static char *custom_strdup(const char *ptr)
{
seen++;
- return (strdup)(ptr);
+#ifdef _WIN32
+ return _strdup(ptr);
+#else
+ /* !checksrc! disable BANNEDFUNC 1 */
+ return strdup(ptr);
+#endif
}
static void *custom_realloc(void *ptr, size_t size)
{
seen++;
- return (realloc)(ptr, size);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ return realloc(ptr, size);
}
static void custom_free(void *ptr)
{
seen++;
- (free)(ptr);
+ /* !checksrc! disable BANNEDFUNC 1 */
+ free(ptr);
}
return TEST_ERR_MAJOR_BAD;
}
- test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses strdup() */
+ test_setopt(curl, CURLOPT_USERAGENT, "test509"); /* uses curlx_strdup() */
asize = (int)sizeof(a);
- str = curl_easy_escape(curl, (const char *)a, asize); /* uses realloc() */
+ /* uses curlx_realloc() */
+ str = curl_easy_escape(curl, (const char *)a, asize);
if(seen)
curl_mprintf("Callbacks were invoked!\n");
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t510_WriteThis {
int counter;
};
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib511(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* Test case code based on source in a bug report filed by James Bursa on
28 Apr 2004 */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static size_t t513_read_cb(char *ptr, size_t size, size_t nmemb, void *userp)
{
(void)ptr;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib514(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib515(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib516(const char *URL)
{
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib517(const char *URL)
{
struct dcheck {
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
#ifndef FD_SETSIZE
#error "this test requires FD_SETSIZE"
t518_num_open.rlim_cur++)
if(t518_testfd[t518_num_open.rlim_cur] > 0)
close(t518_testfd[t518_num_open.rlim_cur]);
- free(t518_testfd);
+ curlx_free(t518_testfd);
t518_testfd = NULL;
}
* avoid a low memory condition once the file descriptors are
* open. System conditions that could make the test fail should
* be addressed in the precheck phase. This chunk of memory shall
- * be always free()ed before exiting the t518_test_rlimit() function so
- * that it becomes available to the test.
+ * be always curlx_free()ed before exiting the t518_test_rlimit()
+ * function so that it becomes available to the test.
*/
for(nitems = i = 1; nitems <= i; i *= 2)
t518_num_open.rlim_max = sizeof(*memchunk) * nitems;
tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
- memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
+ memchunk = curlx_malloc(sizeof(*memchunk) * (size_t)nitems);
if(!memchunk) {
curl_mfprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2;
t518_num_open.rlim_max = NUM_OPEN;
- /* verify that we do not overflow size_t in malloc() */
+ /* verify that we do not overflow size_t in curlx_malloc() */
if((size_t)(t518_num_open.rlim_max) > ((size_t)-1) / sizeof(*t518_testfd)) {
tutil_rlim2str(strbuff1, sizeof(strbuff1), t518_num_open.rlim_max);
"file descriptors, would overflow size_t", strbuff1);
t518_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
- free(memchunk);
+ curlx_free(memchunk);
return -6;
}
tutil_rlim2str(strbuff, sizeof(strbuff), t518_num_open.rlim_max);
curl_mfprintf(stderr, "allocating array for %s file descriptors\n", strbuff);
- t518_testfd = malloc(sizeof(*t518_testfd) *
- (size_t)(t518_num_open.rlim_max));
+ t518_testfd = curlx_malloc(sizeof(*t518_testfd) *
+ (size_t)(t518_num_open.rlim_max));
if(!t518_testfd) {
t518_store_errmsg("testfd, malloc() failed", errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
- free(memchunk);
+ curlx_free(memchunk);
return -7;
}
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t518_store_errmsg(strbuff, errno);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
- free(t518_testfd);
+ curlx_free(t518_testfd);
t518_testfd = NULL;
- free(memchunk);
+ curlx_free(memchunk);
return -8;
}
t518_testfd[t518_num_open.rlim_cur] >= 0;
t518_num_open.rlim_cur++)
close(t518_testfd[t518_num_open.rlim_cur]);
- free(t518_testfd);
+ curlx_free(t518_testfd);
t518_testfd = NULL;
- free(memchunk);
+ curlx_free(memchunk);
return -9;
}
}
t518_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
t518_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -10;
}
t518_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t518_msgbuff);
t518_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -11;
}
}
"fopen fails with lots of fds open");
t518_store_errmsg(strbuff, 0);
t518_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -12;
}
/* free the chunk of memory we were reserving so that it
becomes available to the test */
- free(memchunk);
+ curlx_free(memchunk);
/* close file descriptors unless instructed to keep them */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib519(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib520(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib521(const char *URL)
{
CURLcode res = TEST_ERR_MAJOR_BAD;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib523(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib524(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib525(const char *URL)
{
CURLcode res = CURLE_OK;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib526(const char *URL)
{
CURLcode res = CURLE_OK;
#include "first.h"
-#include "memdebug.h"
-
-
static struct t530_ctx {
int socket_calls;
int max_socket_calls;
* Allocate array storage when required.
*/
if(!sockets->sockets) {
- sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
+ sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U);
if(!sockets->sockets)
return 1;
sockets->max_count = 20;
}
else if(sockets->count + 1 > sockets->max_count) {
- curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) *
- (sockets->max_count + 20));
+ curl_socket_t *ptr = curlx_realloc(sockets->sockets,
+ sizeof(curl_socket_t) *
+ (sockets->max_count + 20));
if(!ptr)
/* cleanup in test_cleanup */
return 1;
curl_global_cleanup();
/* free local memory */
- free(sockets.read.sockets);
- free(sockets.write.sockets);
+ curlx_free(sockets.read.sockets);
+ curlx_free(sockets.write.sockets);
t530_msg("done");
return res;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib533(const char *URL)
{
CURLcode res = CURLE_OK;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static void proxystat(CURL *curl)
{
long wasproxy;
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
#if !defined(HAVE_POLL) && !defined(USE_WINSOCK) && !defined(FD_SETSIZE)
#error "this test requires FD_SETSIZE"
t537_num_open.rlim_cur++)
if(t537_testfd[t537_num_open.rlim_cur] > 0)
close(t537_testfd[t537_num_open.rlim_cur]);
- free(t537_testfd);
+ curlx_free(t537_testfd);
t537_testfd = NULL;
}
* avoid a low memory condition once the file descriptors are
* open. System conditions that could make the test fail should
* be addressed in the precheck phase. This chunk of memory shall
- * be always free()ed before exiting the t537_test_rlimit() function so
- * that it becomes available to the test.
+ * be always curlx_free()ed before exiting the t537_test_rlimit()
+ * function so that it becomes available to the test.
*/
for(nitems = i = 1; nitems <= i; i *= 2)
t537_num_open.rlim_max = sizeof(*memchunk) * nitems;
tutil_rlim2str(strbuff, sizeof(strbuff), t537_num_open.rlim_max);
curl_mfprintf(stderr, "allocating memchunk %s byte array\n", strbuff);
- memchunk = malloc(sizeof(*memchunk) * (size_t)nitems);
+ memchunk = curlx_malloc(sizeof(*memchunk) * (size_t)nitems);
if(!memchunk) {
curl_mfprintf(stderr, "memchunk, malloc() failed\n");
nitems /= 2;
t537_num_open.rlim_max = nitems;
}
- /* verify that we do not overflow size_t in malloc() */
+ /* verify that we do not overflow size_t in curlx_malloc() */
if((size_t)(t537_num_open.rlim_max) > ((size_t)-1) / sizeof(*t537_testfd)) {
tutil_rlim2str(strbuff1, sizeof(strbuff1), t537_num_open.rlim_max);
"file descriptors, would overflow size_t", strbuff1);
t537_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
- free(memchunk);
+ curlx_free(memchunk);
return -5;
}
curl_mfprintf(stderr, "allocating array for %s file descriptors\n",
strbuff);
- t537_testfd = malloc(sizeof(*t537_testfd) *
- (size_t)(t537_num_open.rlim_max));
+ t537_testfd = curlx_malloc(sizeof(*t537_testfd) *
+ (size_t)(t537_num_open.rlim_max));
if(!t537_testfd) {
curl_mfprintf(stderr, "testfd, malloc() failed\n");
t537_num_open.rlim_max /= 2;
if(!t537_testfd) {
t537_store_errmsg("testfd, malloc() failed", errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
- free(memchunk);
+ curlx_free(memchunk);
return -6;
}
curl_msnprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL);
t537_store_errmsg(strbuff, errno);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
- free(t537_testfd);
+ curlx_free(t537_testfd);
t537_testfd = NULL;
- free(memchunk);
+ curlx_free(memchunk);
return -7;
}
/* we do not care if we cannot shrink it */
- tmpfd = realloc(t537_testfd,
- sizeof(*t537_testfd) * (size_t)(t537_num_open.rlim_max));
+ tmpfd = curlx_realloc(t537_testfd,
+ sizeof(*t537_testfd) *
+ (size_t)(t537_num_open.rlim_max));
if(tmpfd) {
t537_testfd = tmpfd;
tmpfd = NULL;
t537_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
t537_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -8;
}
t537_store_errmsg(strbuff, 0);
curl_mfprintf(stderr, "%s\n", t537_msgbuff);
t537_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -9;
}
}
"fopen fails with lots of fds open");
t537_store_errmsg(strbuff, 0);
t537_close_file_descriptors();
- free(memchunk);
+ curlx_free(memchunk);
return -10;
}
/* free the chunk of memory we were reserving so that it
becomes available to the test */
- free(memchunk);
+ curlx_free(memchunk);
/* close file descriptors unless instructed to keep them */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib539(const char *URL)
{
CURLcode res;
#include "first.h"
-#include "memdebug.h"
-
static CURL *t540_curl[2];
static CURLcode init(int num, CURLM *multi, const char *url,
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Two FTP uploads, the second with no content sent.
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* FTP get with NOBODY but no HEADER
*/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib543(const char *URL)
{
static const unsigned char a[] = {
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib544(const char *URL)
{
CURL *curl;
#include "first.h"
-#include "memdebug.h"
-
static const char t547_uploadthis[] = "this is the blurb we want to upload\n";
#define T547_DATALEN (sizeof(t547_uploadthis)-1)
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib549(const char *URL)
{
CURLcode res;
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static size_t current_offset = 0;
static char databuf[70000]; /* MUST be more than 64k OR
#include "first.h"
-#include "memdebug.h"
-
#define POSTLEN 40960
static size_t myreadfunc(char *ptr, size_t size, size_t nmemb, void *stream)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t554_WriteThis {
const char *readptr;
size_t sizeleft;
#include "first.h"
-#include "memdebug.h"
-
static const char t555_uploadthis[] = "this is the blurb we want to upload\n";
#define T555_DATALEN (sizeof(t555_uploadthis)-1)
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib556(const char *URL)
{
CURLcode res;
# include <locale.h> /* for setlocale() */
#endif
-#include "memdebug.h"
-
#if defined(CURL_GNUC_DIAG) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat"
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib558(const char *URL)
{
unsigned char a[] = {0x2f, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
return TEST_ERR_MAJOR_BAD;
}
- ptr = malloc(558);
+ ptr = curlx_malloc(558);
Curl_safefree(ptr);
asize = (int)sizeof(a);
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib559(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Simply download an HTTPS file!
*
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* From "KNOWN_BUGS" April 2009:
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
static CURLcode test_lib564(const char *URL)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib566(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Test a simple OPTIONS request with a custom header
*/
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
/*
* Test the Client->Server ANNOUNCE functionality (PUT style)
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
/*
* Test Session ID capture
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
static CURLcode test_lib570(const char *URL)
{
#endif
#include "testutil.h"
-#include "memdebug.h"
#define RTP_PKT_CHANNEL(p) ((int)((unsigned char)((p)[1])))
#include "first.h"
#include "testutil.h"
-#include "memdebug.h"
/*
* Test GET_PARAMETER: PUT, HEARTBEAT, and POST
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
/*
* Get a single URL without select().
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static int new_fnmatch(void *ptr,
const char *pattern, const char *string)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* 3x download!
* 1. normal
* 2. dup handle
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct chunk_data {
int remains;
int print_content;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* The size of data should be kept below MAX_INITIAL_POST_SIZE! */
static char t578_testdata[] = "this is a short string.\n";
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t579_WriteThis {
int counter;
};
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t582_Sockets {
curl_socket_t *sockets;
int count; /* number of sockets actually stored in array */
* Allocate array storage when required.
*/
if(!sockets->sockets) {
- sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
+ sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U);
if(!sockets->sockets)
return;
sockets->max_count = 20;
curlx_fclose(hd_src);
/* free local memory */
- free(sockets.read.sockets);
- free(sockets.write.sockets);
+ curlx_free(sockets.read.sockets);
+ curlx_free(sockets.write.sockets);
return res;
}
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib583(const char *URL)
{
int stillRunning;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#define THREADS 2
/* struct containing data of a thread */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib589(const char *URL)
{
CURL *curl;
- Start the request
*/
-#include "memdebug.h"
-
static CURLcode test_lib590(const char *URL)
{
CURLcode res;
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib591(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Test case for below scenario:
* - Connect to an FTP server using CONNECT_ONLY option
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib598(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static int t599_progress_callback(void *clientp, double dltotal,
double dlnow, double ultotal, double ulnow)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t643_WriteThis {
const char *readptr;
curl_off_t sizeleft;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* This test attempts to use all form API features that are not
* used elsewhere.
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib651(const char *URL)
{
static char testbuf[17000]; /* more than 16K */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib652(const char *URL)
{
static char testbuf[17000]; /* more than 16K */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib653(const char *URL)
{
CURL *curl = NULL;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t654_WriteThis {
const char *readptr;
curl_off_t sizeleft;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static const char *TEST_DATA_STRING = "Test data";
static int cb_count = 0;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Get a single URL without select().
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Get a single URL without select().
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib661(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib666(const char *URL)
{
static char testbuf[17000]; /* more than 16K */
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t667_WriteThis {
const char *readptr;
curl_off_t sizeleft;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
struct t668_WriteThis {
const char *readptr;
curl_off_t sizeleft;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
#define PAUSE_TIME 5
struct t670_ReadThis {
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Get a single URL without select().
*/
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib676(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib677(const char *URL)
{
static const char testcmd[] = "A1 IDLE\r\n";
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static int loadfile(const char *filename, void **filedata, size_t *filesize)
{
size_t datasize = 0;
if(continue_reading)
continue_reading = fseek(fInCert, 0, SEEK_SET) == 0;
if(continue_reading)
- data = malloc(datasize + 1);
+ data = curlx_malloc(datasize + 1);
if((!data) ||
((int)fread(data, datasize, 1, fInCert) != 1))
continue_reading = FALSE;
curlx_fclose(fInCert);
if(!continue_reading) {
- free(data);
+ curlx_free(data);
datasize = 0;
data = NULL;
}
blob.len = certsize;
blob.flags = CURL_BLOB_COPY;
curl_easy_setopt(curl, CURLOPT_CAINFO_BLOB, &blob);
- free(certdata);
+ curlx_free(certdata);
code = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
static CURLcode test_lib694(const char *URL)
{
CURLcode res;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* write callback that does nothing */
static size_t write_it(char *ptr, size_t size, size_t nmemb, void *userdata)
{
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/*
* Get a single URL without select().
*/
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
struct t753_transfer_status {
CURL *curl;
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
-
/* write callback that does nothing */
static size_t write_757(char *ptr, size_t size, size_t nmemb, void *userdata)
{
#include "first.h"
#include "testtrace.h"
-#include "memdebug.h"
#ifdef USE_OPENSSL
* Allocate array storage when required.
*/
if(!sockets->sockets) {
- sockets->sockets = malloc(sizeof(curl_socket_t) * 20U);
+ sockets->sockets = curlx_malloc(sizeof(curl_socket_t) * 20U);
if(!sockets->sockets)
return 1;
sockets->max_count = 20;
}
else if(sockets->count + 1 > sockets->max_count) {
- curl_socket_t *ptr = realloc(sockets->sockets, sizeof(curl_socket_t) *
- (sockets->max_count + 20));
+ curl_socket_t *ptr = curlx_realloc(sockets->sockets,
+ sizeof(curl_socket_t) *
+ (sockets->max_count + 20));
if(!ptr)
/* cleanup in test_cleanup */
return 1;
curl_global_cleanup();
/* free local memory */
- free(sockets.read.sockets);
- free(sockets.write.sockets);
+ curlx_free(sockets.read.sockets);
+ curlx_free(sockets.write.sockets);
t758_msg("done");
return res;
#include "first.h"
-#include "memdebug.h"
-
static int sockopt_766(void *clientp,
curl_socket_t curlfd,
curlsocktype purpose)
***************************************************************************/
#include "first.h"
-#include "curl_memory.h"
-
#ifndef CURL_STATICLIB
#if defined(_MSC_VER) && defined(_DLL)
*
***************************************************************************/
#include "first.h"
-#include "memdebug.h"
/* This source code is generated by mk-lib1521.pl ! */
***************************************************************************/
#include "testtrace.h"
-#include "memdebug.h"
-
struct libtest_trace_cfg debug_config;
static time_t epoch_offset; /* for test time tracing */
***************************************************************************/
#include "testutil.h"
-#include "memdebug.h"
-
/* build request URL */
char *tutil_suburl(const char *base, int i)
{
# SPDX-License-Identifier: curl
allowfunc accept
+allowfunc calloc
allowfunc fprintf
+allowfunc free
allowfunc freeaddrinfo
allowfunc getaddrinfo
+allowfunc malloc
allowfunc printf
+allowfunc realloc
allowfunc recv
allowfunc send
allowfunc snprintf
allowfunc socket
allowfunc sscanf
+allowfunc strdup
allowfunc vsnprintf
+++ /dev/null
-#!/usr/bin/env perl
-#***************************************************************************
-# _ _ ____ _
-# Project ___| | | | _ \| |
-# / __| | | | |_) | |
-# | (__| |_| | _ <| |___
-# \___|\___/|_| \_\_____|
-#
-# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
-#
-# This software is licensed as described in the file COPYING, which
-# you should have received as part of this distribution. The terms
-# are also available at https://curl.se/docs/copyright.html.
-#
-# You may opt to use, copy, modify, merge, publish, distribute and/or sell
-# copies of the Software, and permit persons to whom the Software is
-# furnished to do so, under the terms of the COPYING file.
-#
-# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
-# KIND, either express or implied.
-#
-# SPDX-License-Identifier: curl
-#
-###########################################################################
-#
-# This script scans C source files. If they seem to use memory functions,
-# it also makes sure that it #includes the correct two header files!
-#
-# You can also mark a C source as fine by using 'mem-include-scan' anywhere in
-# it.
-#
-
-use strict;
-use warnings;
-
-my $dir = $ARGV[0] || die "specify directory!";
-
-sub scanfile {
- my ($file) = @_;
- my $memfunc;
- my $memdebug;
- my $curlmem;
-
- print STDERR "checking $file...\n";
-
- open(my $f, "<", "$file");
- while(<$f>) {
- if($_ =~ /\W(free|alloc|strdup)\(/) {
- $memfunc++;
- }
- elsif($_ =~ /^ *# *include \"memdebug.h\"/) {
- $memdebug++;
- }
- elsif($_ =~ /^ *# *include \"curl_memory.h\"/) {
- $curlmem++;
- }
- elsif($_ =~ /mem-include-scan/) {
- # free pass
- close($f);
- return 0;
- }
- if($memfunc && $memdebug && $curlmem) {
- last;
- }
- }
- close($f);
-
-
- if($memfunc) {
- if($memdebug && $curlmem) {
- return 0;
- }
- else {
- if(!$memdebug) {
- print STDERR "$file does not include \"memdebug.h\"!\n";
- }
- if(!$curlmem) {
- print STDERR "$file does not include \"curl_memory.h\"!\n";
- }
- return 1;
- }
- }
- return 0;
-}
-
-opendir(my $dh, $dir) || die "cannot opendir $dir: $!";
-my @cfiles = grep { /\.c\z/ && -f "$dir/$_" } readdir($dh);
-closedir $dh;
-
-my $errs;
-for(@cfiles) {
- $errs += scanfile("$dir/$_");
-}
-
-if($errs) {
- print STDERR "----\n$errs errors detected!\n";
- exit 2;
-}
#include "tool_getparam.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode test_tool1394(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
}
}
if(certname)
- free(certname);
+ curlx_free(certname);
if(passphrase)
- free(passphrase);
+ curlx_free(passphrase);
}
UNITTEST_END_SIMPLE
#include "tool_cfgable.h"
#include "tool_doswin.h"
-#include "memdebug.h" /* LAST include file */
-
#if defined(_WIN32) || defined(MSDOS)
static char *getflagstr(int flags)
{
- char *buf = malloc(256);
+ char *buf = curlx_malloc(256);
if(buf) {
curl_msnprintf(buf, 256, "%s,%s",
((flags & SANITIZE_ALLOW_PATH) ?
static char *getcurlcodestr(int cc)
{
- char *buf = malloc(256);
+ char *buf = curlx_malloc(256);
if(buf) {
curl_msnprintf(buf, 256, "%s (%d)",
(cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
((!output && !data[i].expected_output) ||
(output && data[i].expected_output &&
!strcmp(output, data[i].expected_output)))) { /* OK */
- free(output);
+ curlx_free(output);
continue;
}
data[i].expected_output ? data[i].expected_output : "(null)",
expected_ccstr);
- free(output);
- free(flagstr);
- free(received_ccstr);
- free(expected_ccstr);
+ curlx_free(output);
+ curlx_free(flagstr);
+ curlx_free(received_ccstr);
+ curlx_free(expected_ccstr);
}
/* END sanitize_file_name */
#else
#include "tool_xattr.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode test_tool1621(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
#include "urldata.h"
#include "url.h" /* for Curl_safefree */
-#include "memdebug.h" /* LAST include file */
struct etest {
const char *input;
#include "urldata.h"
#include "connect.h"
-#include "memdebug.h" /* LAST include file */
static CURLcode t1303_setup(struct Curl_easy **easy)
{
***************************************************************************/
#include "unitcheck.h"
#include "netrc.h"
-#include "memdebug.h" /* LAST include file */
#ifndef CURL_DISABLE_NETRC
* Test for the first existing host in our netrc file
* with login[0] != 0.
*/
- free(password);
- free(login);
+ curlx_free(password);
+ curlx_free(login);
password = NULL;
login = NULL;
Curl_netrc_init(&store);
* Test for the second existing host in our netrc file
* with login[0] = 0.
*/
- free(password);
+ curlx_free(password);
password = NULL;
- free(login);
+ curlx_free(login);
login = NULL;
Curl_netrc_init(&store);
result = Curl_parsenetrc(&store,
* Test for the second existing host in our netrc file
* with login[0] != 0.
*/
- free(password);
+ curlx_free(password);
password = NULL;
- free(login);
+ curlx_free(login);
login = NULL;
Curl_netrc_init(&store);
result = Curl_parsenetrc(&store,
#include "hash.h"
#include "hostip.h"
-#include "memdebug.h" /* LAST include file */
-
static struct Curl_dnscache hp;
static char *data_key;
static struct Curl_dns_entry *data_node;
{
if(data_node) {
Curl_freeaddrinfo(data_node->addr);
- free(data_node);
+ curlx_free(data_node);
}
- free(data_key);
+ curlx_free(data_key);
Curl_dnscache_destroy(&hp);
}
static const char dummy[] = "dummy";
size_t namelen = sizeof(dummy); /* including the null-terminator */
- ai = calloc(1, sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) +
- namelen);
+ ai = curlx_calloc(1,
+ sizeof(struct Curl_addrinfo) + sizeof(struct sockaddr_in) +
+ namelen);
if(!ai)
return NULL;
if(!data_key)
return CURLE_OUT_OF_MEMORY;
- data_node = calloc(1, sizeof(struct Curl_dns_entry));
+ data_node = curlx_calloc(1, sizeof(struct Curl_dns_entry));
if(!data_node)
return CURLE_OUT_OF_MEMORY;
***************************************************************************/
#include "unitcheck.h"
-#include "memdebug.h"
-
static CURLcode test_unit1330(const char *arg)
{
UNITTEST_BEGIN_SIMPLE
- char *ptr = malloc(1330);
+ char *ptr = curlx_malloc(1330);
Curl_safefree(ptr);
UNITTEST_END_SIMPLE
*
***************************************************************************/
#include "unitcheck.h"
-#include "memdebug.h"
#include "unitprotos.h"
static CURLcode test_unit1395(const char *arg)
}
else
curl_mfprintf(stderr, "Test %u: OK\n", i);
- free(out);
+ curlx_free(out);
}
fail_if(fails, "output mismatched");
#include "hash.h"
-#include "memdebug.h" /* LAST include file */
-
static void t1602_mydtor(void *p)
{
int *ptr = (int *)p;
- free(ptr);
+ curlx_free(ptr);
}
static CURLcode t1602_setup(struct Curl_hash *hash)
int key = 20;
int key2 = 25;
- value = malloc(sizeof(int));
+ value = curlx_malloc(sizeof(int));
abort_unless(value != NULL, "Out of memory");
*value = 199;
nodep = Curl_hash_add(&hash, &key, klen, value);
if(!nodep)
- free(value);
+ curlx_free(value);
abort_unless(nodep, "insertion into hash failed");
Curl_hash_clean(&hash);
/* Attempt to add another key/value pair */
- value2 = malloc(sizeof(int));
+ value2 = curlx_malloc(sizeof(int));
abort_unless(value2 != NULL, "Out of memory");
*value2 = 204;
nodep = Curl_hash_add(&hash, &key2, klen, value2);
if(!nodep)
- free(value2);
+ curlx_free(value2);
abort_unless(nodep, "insertion into hash failed");
UNITTEST_END(t1602_stop(&hash))
#include "hash.h"
-#include "memdebug.h" /* LAST include file */
-
static const size_t slots = 3;
static void t1603_mydtor(void *p)
#include "connect.h"
#include "curl_share.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode t1607_setup(void)
{
CURLcode res = CURLE_OK;
goto error;
dns = Curl_hash_pick(&multi->dnscache.entries,
entry_id, strlen(entry_id) + 1);
- free(entry_id);
+ curlx_free(entry_id);
entry_id = NULL;
addr = dns ? dns->addr : NULL;
#include "connect.h"
#include "curl_share.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode t1609_setup(void)
{
CURLcode res = CURLE_OK;
dns = Curl_hash_pick(&multi->dnscache.entries,
entry_id, strlen(entry_id) + 1);
- free(entry_id);
+ curlx_free(entry_id);
entry_id = NULL;
addr = dns ? dns->addr : NULL;
#include "uint-hash.h"
-#include "memdebug.h" /* LAST include file */
-
static void t1616_mydtor(unsigned int id, void *elem)
{
int *ptr = (int *)elem;
(void)id;
- free(ptr);
+ curlx_free(ptr);
}
static CURLcode t1616_setup(struct uint_hash *hash)
unsigned int key = 20;
unsigned int key2 = 25;
- value = malloc(sizeof(int));
+ value = curlx_malloc(sizeof(int));
abort_unless(value != NULL, "Out of memory");
*value = 199;
ok = Curl_uint32_hash_set(&hash, key, value);
if(!ok)
- free(value);
+ curlx_free(value);
abort_unless(ok, "insertion into hash failed");
v = Curl_uint32_hash_get(&hash, key);
abort_unless(v == value, "lookup present entry failed");
Curl_uint32_hash_clear(&hash);
/* Attempt to add another key/value pair */
- value2 = malloc(sizeof(int));
+ value2 = curlx_malloc(sizeof(int));
abort_unless(value2 != NULL, "Out of memory");
*value2 = 204;
ok = Curl_uint32_hash_set(&hash, key2, value2);
if(!ok)
- free(value2);
+ curlx_free(value2);
abort_unless(ok, "insertion into hash failed");
v = Curl_uint32_hash_get(&hash, key2);
abort_unless(v == value2, "lookup present entry failed");
#include "urldata.h"
#include "url.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode t1620_setup(void)
{
CURLcode res = CURLE_OK;
"options should be equal to exp_options");
}
- free(userstr);
- free(passwdstr);
- free(options);
+ curlx_free(userstr);
+ curlx_free(passwdstr);
+ curlx_free(options);
}
static CURLcode test_unit1620(const char *arg)
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15]");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15|");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15|");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff;fea7:da15]:808");
+ ipv6port = curlx_strdup("[fe80::250:56ff;fea7:da15]:808");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]:80");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]:80");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15%25eth3]");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%25eth3]");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15]:81");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:81");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15];81");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15];81");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15]80");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]80");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15]:");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15]:");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, TRUE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15!25eth3]:180");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15!25eth3]:180");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("[fe80::250:56ff:fea7:da15%eth3]:80");
+ ipv6port = curlx_strdup("[fe80::250:56ff:fea7:da15%eth3]:80");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
u = curl_url();
if(!u)
goto fail;
- ipv6port = strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
- "aaaaaaaaaaaaaaaaaaaaaa:");
+ ipv6port = curlx_strdup("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+ "aaaaaaaaaaaaaaaaaaaaaa:");
if(!ipv6port)
goto fail;
ret = parse_port(u, ipv6port, FALSE);
fail_unless(ret == CURLUE_BAD_PORT_NUMBER, "parse_port did wrong");
fail:
- free(ipv6port);
+ curlx_free(ipv6port);
curl_url_cleanup(u);
UNITTEST_END_SIMPLE
***************************************************************************/
#include "unitcheck.h"
#include "bufref.h"
-#include "memdebug.h"
static int freecount = 0;
{
fail_unless(p, "pointer to free may not be NULL");
freecount++;
- free(p);
+ curlx_free(p);
}
static CURLcode t1661_setup(struct bufref *bufref)
/**
* testing Curl_bufref_set
*/
- buffer = malloc(13);
+ buffer = curlx_malloc(13);
abort_unless(buffer, "Out of memory");
Curl_bufref_set(&bufref, buffer, 13, test_free);
#include "cf-socket.h"
-#include "memdebug.h" /* LAST include file */
-
static CURLcode t1663_setup(void)
{
CURLcode res = CURLE_OK;
"host should be equal to exp_host");
}
- free(dev);
- free(iface);
- free(host);
+ curlx_free(dev);
+ curlx_free(iface);
+ curlx_free(host);
}
static CURLcode test_unit1663(const char *arg)
#include <netinet/in6.h>
#endif
-#include "memdebug.h" /* LAST include file */
-
static CURLcode t1664_setup(void)
{
CURLcode res = CURLE_OK;
#include "multiif.h"
#include "select.h"
#include "curl_trc.h"
-#include "memdebug.h"
static CURLcode t2600_setup(CURL **easy)
{
#else
(void)data;
#endif
- free(ctx);
+ curlx_free(ctx);
cf->ctx = NULL;
}
(void)data;
(void)conn;
- ctx = calloc(1, sizeof(*ctx));
+ ctx = curlx_calloc(1, sizeof(*ctx));
if(!ctx) {
res = CURLE_OUT_OF_MEMORY;
goto out;
out:
*pcf = (!res) ? cf : NULL;
if(res) {
- free(cf);
- free(ctx);
+ curlx_free(cf);
+ curlx_free(ctx);
}
return res;
}
***************************************************************************/
#include "unitcheck.h"
#include "vssh/vssh.h"
-#include "memdebug.h"
static CURLcode test_unit2604(const char *arg)
{
#pragma GCC diagnostic pop
#endif
- char *cp0 = calloc(1, too_long + 1);
+ char *cp0 = curlx_calloc(1, too_long + 1);
fail_unless(cp0, "could not alloc too long value");
memset(cp0, 'a', too_long);
}
}
- free(cp0);
+ curlx_free(cp0);
#endif
***************************************************************************/
#include "unitcheck.h"
#include "vssh/vssh.h"
-#include "memdebug.h"
static CURLcode test_unit2605(const char *arg)
{
***************************************************************************/
#include "unitcheck.h"
#include "curl_get_line.h"
-#include "memdebug.h"
static CURLcode test_unit3200(const char *arg)
{