2 #ifndef _CURL_MEDEBUG_H
3 #define _CURL_MEDEBUG_H
4 /***************************************************************************
6 * Project ___| | | | _ \| |
8 * | (__| |_| | _ <| |___
9 * \___|\___/|_| \_\_____|
11 * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
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 http://curl.haxx.se/docs/copyright.html.
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.
21 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
22 * KIND, either express or implied.
24 * $Id: memdebug.h,v 1.26 2004/02/26 14:52:51 bagder Exp $
25 ***************************************************************************/
28 * CAUTION: this header is designed to work when included by the app-side
29 * as well as the library. Do not mix with library internals!
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 #include <sys/socket.h>
46 #define logfile curl_debuglogfile
50 /* memory functions */
51 void *curl_domalloc(size_t size, int line, const char *source);
52 void *curl_docalloc(size_t elements, size_t size, int line, const char *source);
53 void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
54 void curl_dofree(void *ptr, int line, const char *source);
55 char *curl_dostrdup(const char *str, int line, const char *source);
56 void curl_memdebug(const char *logname);
57 void curl_memlimit(long limit);
59 /* file descriptor manipulators */
60 int curl_socket(int domain, int type, int protocol, int line , const char *);
61 int curl_sclose(int sockfd, int, const char *source);
62 int curl_accept(int s, void *addr, void *addrlen,
63 int line, const char *source);
66 FILE *curl_fopen(const char *file, const char *mode, int line,
68 int curl_fclose(FILE *file, int line, const char *source);
70 #ifndef MEMDEBUG_NODEFINES
72 /* Set this symbol on the command-line, recompile all lib-sources */
74 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
75 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
76 #define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
77 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
78 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
80 #define socket(domain,type,protocol)\
81 curl_socket(domain,type,protocol,__LINE__,__FILE__)
82 #undef accept /* for those with accept as a macro */
83 #define accept(sock,addr,len)\
84 curl_accept(sock,addr,len,__LINE__,__FILE__)
86 #define getaddrinfo(host,serv,hint,res) \
87 curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
88 #define freeaddrinfo(data) \
89 curl_freeaddrinfo(data,__LINE__,__FILE__)
91 /* sclose is probably already defined, redefine it! */
93 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
94 /* ares-adjusted define: */
96 #define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
99 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
100 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
102 #endif /* MEMDEBUG_NODEFINES */
104 #endif /* _CURL_MEDEBUG_H */
105 #endif /* CURLDEBUG */