Skip to content

Commit

Permalink
curl_memory: make curl_memory.h the second-last header file loaded
Browse files Browse the repository at this point in the history
This header file must be included after all header files except
memdebug.h, as it does similar memory function redefinitions and can be
similarly affected by conflicting definitions in system or dependent
library headers.
  • Loading branch information
dfandrich committed Mar 24, 2015
1 parent ac2827a commit 35648f2
Show file tree
Hide file tree
Showing 40 changed files with 101 additions and 80 deletions.
4 changes: 2 additions & 2 deletions lib/base64.c
Expand Up @@ -27,10 +27,10 @@
#include "urldata.h" /* for the SessionHandle definition */
#include "warnless.h"
#include "curl_base64.h"
#include "curl_memory.h"
#include "non-ascii.h"

/* include memdebug.h last */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* ---- Base64 Encoding/Decoding Table --- */
Expand Down
4 changes: 2 additions & 2 deletions lib/connect.c
Expand Up @@ -62,7 +62,6 @@
#include "if2ip.h"
#include "strerror.h"
#include "connect.h"
#include "curl_memory.h"
#include "select.h"
#include "url.h" /* for Curl_safefree() */
#include "multiif.h"
Expand All @@ -75,7 +74,8 @@
#include "conncache.h"
#include "multihandle.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#ifdef __SYMBIAN32__
Expand Down
4 changes: 2 additions & 2 deletions lib/cookie.c
Expand Up @@ -91,14 +91,14 @@ Example set of cookies:
#include "strtok.h"
#include "sendf.h"
#include "slist.h"
#include "curl_memory.h"
#include "share.h"
#include "strtoofft.h"
#include "rawstr.h"
#include "curl_memrchr.h"
#include "inet_pton.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

static void freecookie(struct Cookie *co)
Expand Down
3 changes: 3 additions & 0 deletions lib/curl_memory.h
Expand Up @@ -28,6 +28,9 @@
* 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
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_ntlm.c
Expand Up @@ -41,7 +41,6 @@
#include "curl_ntlm_wb.h"
#include "curl_sasl.h"
#include "url.h"
#include "curl_memory.h"
#include "curl_printf.h"

#if defined(USE_NSS)
Expand All @@ -50,7 +49,8 @@
#include "curl_sspi.h"
#endif

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#if DEBUG_ME
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_ntlm_core.c
Expand Up @@ -101,7 +101,6 @@
#include "urldata.h"
#include "non-ascii.h"
#include "rawstr.h"
#include "curl_memory.h"
#include "curl_ntlm_core.h"
#include "curl_md5.h"
#include "curl_hmac.h"
Expand All @@ -110,7 +109,8 @@
#include "curl_des.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#define NTLM_HMAC_MD5_LEN (16)
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_ntlm_msgs.c
Expand Up @@ -41,7 +41,6 @@
#include "curl_gethostname.h"
#include "curl_multibyte.h"
#include "warnless.h"
#include "curl_memory.h"

#include "vtls/vtls.h"

Expand All @@ -55,7 +54,8 @@
#include "curl_endian.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* "NTLMSSP" signature is always in ASCII regardless of the platform */
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_ntlm_wb.c
Expand Up @@ -51,10 +51,10 @@
#include "curl_ntlm_wb.h"
#include "url.h"
#include "strerror.h"
#include "curl_memory.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#if DEBUG_ME
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_sasl.c
Expand Up @@ -39,15 +39,15 @@
#include "curl_hmac.h"
#include "curl_sasl.h"
#include "warnless.h"
#include "curl_memory.h"
#include "strtok.h"
#include "strequal.h"
#include "rawstr.h"
#include "sendf.h"
#include "non-ascii.h" /* included for Curl_convert_... prototypes */
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* Supported mechanisms */
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_sasl_gssapi.c
Expand Up @@ -33,11 +33,11 @@
#include "urldata.h"
#include "curl_base64.h"
#include "curl_gssapi.h"
#include "curl_memory.h"
#include "sendf.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_sasl_sspi.c
Expand Up @@ -36,13 +36,13 @@
#include "urldata.h"
#include "curl_base64.h"
#include "warnless.h"
#include "curl_memory.h"
#include "curl_multibyte.h"
#include "sendf.h"
#include "strdup.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/curl_sspi.c
Expand Up @@ -26,11 +26,11 @@

#include <curl/curl.h>
#include "curl_sspi.h"
#include "curl_memory.h"
#include "curl_multibyte.h"
#include "warnless.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* We use our own typedef here since some headers might lack these */
Expand Down
4 changes: 2 additions & 2 deletions lib/easy.c
Expand Up @@ -60,7 +60,6 @@
#include "hostip.h"
#include "share.h"
#include "strdup.h"
#include "curl_memory.h"
#include "progress.h"
#include "easyif.h"
#include "select.h"
Expand All @@ -77,7 +76,8 @@
#include "ssh.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* win32_cleanup() is for win32 socket cleanup functionality, the opposite
Expand Down
4 changes: 2 additions & 2 deletions lib/escape.c
Expand Up @@ -27,14 +27,14 @@

#include <curl/curl.h>

#include "curl_memory.h"
#include "urldata.h"
#include "warnless.h"
#include "non-ascii.h"
#include "escape.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* Portable character check (remember EBCDIC). Do not use isalnum() because
Expand Down
4 changes: 2 additions & 2 deletions lib/file.c
Expand Up @@ -59,12 +59,12 @@
#include "getinfo.h"
#include "transfer.h"
#include "url.h"
#include "curl_memory.h"
#include "parsedate.h" /* for the week day and month names */
#include "warnless.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#if defined(WIN32) || defined(MSDOS) || defined(__EMX__) || \
Expand Down
4 changes: 2 additions & 2 deletions lib/formdata.c
Expand Up @@ -34,12 +34,12 @@
#include "formdata.h"
#include "vtls/vtls.h"
#include "strequal.h"
#include "curl_memory.h"
#include "sendf.h"
#include "strdup.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#ifndef HAVE_BASENAME
Expand Down
4 changes: 2 additions & 2 deletions lib/getinfo.c
Expand Up @@ -27,12 +27,12 @@
#include "urldata.h"
#include "getinfo.h"

#include "curl_memory.h"
#include "vtls/vtls.h"
#include "connect.h" /* Curl_getconnectinfo() */
#include "progress.h"

/* Make this the last #include */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/http.c
Expand Up @@ -63,7 +63,6 @@
#include "share.h"
#include "hostip.h"
#include "http.h"
#include "curl_memory.h"
#include "select.h"
#include "parsedate.h" /* for the week day and month names */
#include "strtoofft.h"
Expand All @@ -79,7 +78,8 @@
#include "connect.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/http2.c
Expand Up @@ -30,11 +30,11 @@
#include "http.h"
#include "sendf.h"
#include "curl_base64.h"
#include "curl_memory.h"
#include "rawstr.h"
#include "multiif.h"

/* include memdebug.h last */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#if (NGHTTP2_VERSION_NUM < 0x000600)
Expand Down
4 changes: 2 additions & 2 deletions lib/http_chunks.c
Expand Up @@ -29,12 +29,12 @@

#include "content_encoding.h"
#include "http.h"
#include "curl_memory.h"
#include "non-ascii.h" /* for Curl_convert_to_network prototype */
#include "strtoofft.h"
#include "warnless.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/*
Expand Down
4 changes: 2 additions & 2 deletions lib/http_digest.c
Expand Up @@ -28,10 +28,10 @@
#include "rawstr.h"
#include "curl_sasl.h"
#include "http_digest.h"
#include "curl_memory.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

/* Test example headers:
Expand Down
4 changes: 2 additions & 2 deletions lib/http_negotiate.c
Expand Up @@ -30,12 +30,12 @@
#include "rawstr.h"
#include "curl_base64.h"
#include "http_negotiate.h"
#include "curl_memory.h"
#include "curl_sasl.h"
#include "url.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
Expand Down
4 changes: 2 additions & 2 deletions lib/http_negotiate_sspi.c
Expand Up @@ -33,11 +33,11 @@
#include "curl_base64.h"
#include "curl_sasl.h"
#include "http_negotiate.h"
#include "curl_memory.h"
#include "curl_multibyte.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

CURLcode Curl_input_negotiate(struct connectdata *conn, bool proxy,
Expand Down
4 changes: 2 additions & 2 deletions lib/krb5.c
Expand Up @@ -46,11 +46,11 @@
#include "curl_gssapi.h"
#include "sendf.h"
#include "curl_sec.h"
#include "curl_memory.h"
#include "warnless.h"
#include "curl_printf.h"

/* The last #include file should be: */
/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#define LOCAL_ADDR (&conn->local_addr)
Expand Down
4 changes: 3 additions & 1 deletion lib/ldap.c
Expand Up @@ -72,12 +72,14 @@
#include "strequal.h"
#include "strtok.h"
#include "curl_ldap.h"
#include "curl_memory.h"
#include "curl_multibyte.h"
#include "curl_base64.h"
#include "rawstr.h"
#include "connect.h"
#include "curl_printf.h"

/* The last #include files should be: */
#include "curl_memory.h"
#include "memdebug.h"

#ifndef HAVE_LDAP_URL_PARSE
Expand Down

0 comments on commit 35648f2

Please sign in to comment.