VirtualBox

source: vbox/trunk/src/libs/curl-7.64.0/lib/memdebug.h@ 91528

Last change on this file since 91528 was 85671, checked in by vboxsync, 4 years ago

Export out internal curl copy to make it a lot simpler to build VBox (OSE) on Windows. bugref:9814

  • Property svn:eol-style set to native
File size: 6.7 KB
Line 
1#ifndef HEADER_CURL_MEMDEBUG_H
2#define HEADER_CURL_MEMDEBUG_H
3#ifdef CURLDEBUG
4/***************************************************************************
5 * _ _ ____ _
6 * Project ___| | | | _ \| |
7 * / __| | | | |_) | |
8 * | (__| |_| | _ <| |___
9 * \___|\___/|_| \_\_____|
10 *
11 * Copyright (C) 1998 - 2018, Daniel Stenberg, <[email protected]>, et al.
12 *
13 * This software is licensed as described in the file COPYING, which
14 * you should have received as part of this distribution. The terms
15 * are also available at https://curl.haxx.se/docs/copyright.html.
16 *
17 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
18 * copies of the Software, and permit persons to whom the Software is
19 * furnished to do so, under the terms of the COPYING file.
20 *
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
23 *
24 ***************************************************************************/
25
26/*
27 * CAUTION: this header is designed to work when included by the app-side
28 * as well as the library. Do not mix with library internals!
29 */
30
31#define CURL_MT_LOGFNAME_BUFSIZE 512
32
33#define logfile curl_debuglogfile
34
35extern FILE *logfile;
36
37/* memory functions */
38CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
39CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line,
40 const char *source);
41CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
42 const char *source);
43CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
44CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
45#if defined(WIN32) && defined(UNICODE)
46CURL_EXTERN wchar_t *curl_dowcsdup(const wchar_t *str, int line,
47 const char *source);
48#endif
49
50CURL_EXTERN void curl_memdebug(const char *logname);
51CURL_EXTERN void curl_memlimit(long limit);
52CURL_EXTERN void curl_memlog(const char *format, ...);
53
54/* file descriptor manipulators */
55CURL_EXTERN curl_socket_t curl_socket(int domain, int type, int protocol,
56 int line, const char *source);
57CURL_EXTERN void curl_mark_sclose(curl_socket_t sockfd,
58 int line, const char *source);
59CURL_EXTERN int curl_sclose(curl_socket_t sockfd,
60 int line, const char *source);
61CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen,
62 int line, const char *source);
63#ifdef HAVE_SOCKETPAIR
64CURL_EXTERN int curl_socketpair(int domain, int type, int protocol,
65 curl_socket_t socket_vector[2],
66 int line, const char *source);
67#endif
68
69/* send/receive sockets */
70CURL_EXTERN SEND_TYPE_RETV curl_dosend(SEND_TYPE_ARG1 sockfd,
71 SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
72 SEND_TYPE_ARG3 len,
73 SEND_TYPE_ARG4 flags, int line,
74 const char *source);
75CURL_EXTERN RECV_TYPE_RETV curl_dorecv(RECV_TYPE_ARG1 sockfd,
76 RECV_TYPE_ARG2 buf, RECV_TYPE_ARG3 len,
77 RECV_TYPE_ARG4 flags, int line,
78 const char *source);
79
80/* FILE functions */
81CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
82 const char *source);
83#ifdef HAVE_FDOPEN
84CURL_EXTERN FILE *curl_fdopen(int filedes, const char *mode, int line,
85 const char *source);
86#endif
87CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
88
89#ifndef MEMDEBUG_NODEFINES
90
91/* Set this symbol on the command-line, recompile all lib-sources */
92#undef strdup
93#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
94#define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
95#define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
96#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
97#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
98#define send(a,b,c,d) curl_dosend(a,b,c,d, __LINE__, __FILE__)
99#define recv(a,b,c,d) curl_dorecv(a,b,c,d, __LINE__, __FILE__)
100
101#ifdef WIN32
102# ifdef UNICODE
103# undef wcsdup
104# define wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
105# undef _wcsdup
106# define _wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
107# undef _tcsdup
108# define _tcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
109# else
110# undef _tcsdup
111# define _tcsdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
112# endif
113#endif
114
115#undef socket
116#define socket(domain,type,protocol)\
117 curl_socket(domain, type, protocol, __LINE__, __FILE__)
118#undef accept /* for those with accept as a macro */
119#define accept(sock,addr,len)\
120 curl_accept(sock, addr, len, __LINE__, __FILE__)
121#ifdef HAVE_SOCKETPAIR
122#define socketpair(domain,type,protocol,socket_vector)\
123 curl_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
124#endif
125
126#ifdef HAVE_GETADDRINFO
127#if defined(getaddrinfo) && defined(__osf__)
128/* OSF/1 and Tru64 have getaddrinfo as a define already, so we cannot define
129 our macro as for other platforms. Instead, we redefine the new name they
130 define getaddrinfo to become! */
131#define ogetaddrinfo(host,serv,hint,res) \
132 curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
133#else
134#undef getaddrinfo
135#define getaddrinfo(host,serv,hint,res) \
136 curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
137#endif
138#endif /* HAVE_GETADDRINFO */
139
140#ifdef HAVE_FREEADDRINFO
141#undef freeaddrinfo
142#define freeaddrinfo(data) \
143 curl_dofreeaddrinfo(data, __LINE__, __FILE__)
144#endif /* HAVE_FREEADDRINFO */
145
146/* sclose is probably already defined, redefine it! */
147#undef sclose
148#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
149
150#define fake_sclose(sockfd) curl_mark_sclose(sockfd,__LINE__,__FILE__)
151
152#undef fopen
153#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
154#undef fdopen
155#define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
156#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
157
158#endif /* MEMDEBUG_NODEFINES */
159
160#endif /* CURLDEBUG */
161
162/*
163** Following section applies even when CURLDEBUG is not defined.
164*/
165
166#ifndef fake_sclose
167#define fake_sclose(x) Curl_nop_stmt
168#endif
169
170/*
171 * Curl_safefree defined as a macro to allow MemoryTracking feature
172 * to log free() calls at same location where Curl_safefree is used.
173 * This macro also assigns NULL to given pointer when free'd.
174 */
175
176#define Curl_safefree(ptr) \
177 do { free((ptr)); (ptr) = NULL;} WHILE_FALSE
178
179#endif /* HEADER_CURL_MEMDEBUG_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette