memdebug.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_MEMDEBUG_H
00002 #define HEADER_CURL_MEMDEBUG_H
00003 #ifdef CURLDEBUG
00004 /***************************************************************************
00005  *                                  _   _ ____  _
00006  *  Project                     ___| | | |  _ \| |
00007  *                             / __| | | | |_) | |
00008  *                            | (__| |_| |  _ <| |___
00009  *                             \___|\___/|_| \_\_____|
00010  *
00011  * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
00012  *
00013  * This software is licensed as described in the file COPYING, which
00014  * you should have received as part of this distribution. The terms
00015  * are also available at https://curl.haxx.se/docs/copyright.html.
00016  *
00017  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00018  * copies of the Software, and permit persons to whom the Software is
00019  * furnished to do so, under the terms of the COPYING file.
00020  *
00021  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00022  * KIND, either express or implied.
00023  *
00024  ***************************************************************************/
00025 
00026 /*
00027  * CAUTION: this header is designed to work when included by the app-side
00028  * as well as the library. Do not mix with library internals!
00029  */
00030 
00031 #define CURL_MT_LOGFNAME_BUFSIZE 512
00032 
00033 #define logfile curl_debuglogfile
00034 
00035 extern FILE *logfile;
00036 
00037 /* memory functions */
00038 CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
00039 CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line,
00040                                 const char *source);
00041 CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
00042                                  const char *source);
00043 CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
00044 CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
00045 #if defined(WIN32) && defined(UNICODE)
00046 CURL_EXTERN wchar_t *curl_dowcsdup(const wchar_t *str, int line,
00047                                    const char *source);
00048 #endif
00049 
00050 CURL_EXTERN void curl_memdebug(const char *logname);
00051 CURL_EXTERN void curl_memlimit(long limit);
00052 CURL_EXTERN void curl_memlog(const char *format, ...);
00053 
00054 /* file descriptor manipulators */
00055 CURL_EXTERN curl_socket_t curl_socket(int domain, int type, int protocol,
00056                                       int line, const char *source);
00057 CURL_EXTERN void curl_mark_sclose(curl_socket_t sockfd,
00058                                   int line, const char *source);
00059 CURL_EXTERN int curl_sclose(curl_socket_t sockfd,
00060                             int line, const char *source);
00061 CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen,
00062                                       int line, const char *source);
00063 #ifdef HAVE_SOCKETPAIR
00064 CURL_EXTERN int curl_socketpair(int domain, int type, int protocol,
00065                                 curl_socket_t socket_vector[2],
00066                                 int line, const char *source);
00067 #endif
00068 
00069 /* FILE functions */
00070 CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
00071                              const char *source);
00072 #ifdef HAVE_FDOPEN
00073 CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line,
00074                               const char *source);
00075 #endif
00076 CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
00077 
00078 #ifndef MEMDEBUG_NODEFINES
00079 
00080 /* Set this symbol on the command-line, recompile all lib-sources */
00081 #undef strdup
00082 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
00083 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
00084 #define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
00085 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
00086 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
00087 
00088 #ifdef WIN32
00089 #  ifdef UNICODE
00090 #    undef wcsdup
00091 #    define wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
00092 #    undef _wcsdup
00093 #    define _wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
00094 #    undef _tcsdup
00095 #    define _tcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
00096 #  else
00097 #    undef _tcsdup
00098 #    define _tcsdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
00099 #  endif
00100 #endif
00101 
00102 #undef socket
00103 #define socket(domain,type,protocol)\
00104  curl_socket(domain, type, protocol, __LINE__, __FILE__)
00105 #undef accept /* for those with accept as a macro */
00106 #define accept(sock,addr,len)\
00107  curl_accept(sock, addr, len, __LINE__, __FILE__)
00108 #ifdef HAVE_SOCKETPAIR
00109 #define socketpair(domain,type,protocol,socket_vector)\
00110  curl_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
00111 #endif
00112 
00113 #ifdef HAVE_GETADDRINFO
00114 #if defined(getaddrinfo) && defined(__osf__)
00115 /* OSF/1 and Tru64 have getaddrinfo as a define already, so we cannot define
00116    our macro as for other platforms. Instead, we redefine the new name they
00117    define getaddrinfo to become! */
00118 #define ogetaddrinfo(host,serv,hint,res) \
00119   curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
00120 #else
00121 #undef getaddrinfo
00122 #define getaddrinfo(host,serv,hint,res) \
00123   curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
00124 #endif
00125 #endif /* HAVE_GETADDRINFO */
00126 
00127 #ifdef HAVE_GETNAMEINFO
00128 #undef getnameinfo
00129 #define getnameinfo(sa,salen,host,hostlen,serv,servlen,flags) \
00130   curl_dogetnameinfo(sa, salen, host, hostlen, serv, servlen, flags, \
00131                      __LINE__, __FILE__)
00132 #endif /* HAVE_GETNAMEINFO */
00133 
00134 #ifdef HAVE_FREEADDRINFO
00135 #undef freeaddrinfo
00136 #define freeaddrinfo(data) \
00137   curl_dofreeaddrinfo(data, __LINE__, __FILE__)
00138 #endif /* HAVE_FREEADDRINFO */
00139 
00140 /* sclose is probably already defined, redefine it! */
00141 #undef sclose
00142 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
00143 
00144 #define fake_sclose(sockfd) curl_mark_sclose(sockfd,__LINE__,__FILE__)
00145 
00146 #undef fopen
00147 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
00148 #undef fdopen
00149 #define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
00150 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
00151 
00152 #endif /* MEMDEBUG_NODEFINES */
00153 
00154 #endif /* CURLDEBUG */
00155 
00156 /*
00157 ** Following section applies even when CURLDEBUG is not defined.
00158 */
00159 
00160 #ifndef fake_sclose
00161 #define fake_sclose(x)  Curl_nop_stmt
00162 #endif
00163 
00164 /*
00165  * Curl_safefree defined as a macro to allow MemoryTracking feature
00166  * to log free() calls at same location where Curl_safefree is used.
00167  * This macro also assigns NULL to given pointer when free'd.
00168  */
00169 
00170 #define Curl_safefree(ptr) \
00171   do { free((ptr)); (ptr) = NULL;} WHILE_FALSE
00172 
00173 #endif /* HEADER_CURL_MEMDEBUG_H */


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05