]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/curl/lib/memdebug.h
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / curl / lib / memdebug.h
1 #ifdef CURLDEBUG
2 #ifndef _CURL_MEDEBUG_H
3 #define _CURL_MEDEBUG_H
4 /***************************************************************************
5  *                                  _   _ ____  _     
6  *  Project                     ___| | | |  _ \| |    
7  *                             / __| | | | |_) | |    
8  *                            | (__| |_| |  _ <| |___ 
9  *                             \___|\___/|_| \_\_____|
10  *
11  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, 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 http://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  * $Id: memdebug.h,v 1.26 2004/02/26 14:52:51 bagder Exp $
25  ***************************************************************************/
26
27 /*
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!
30  */
31
32 #include "setup.h"
33
34 #ifdef HAVE_SYS_TYPES_H
35 #include <sys/types.h>
36 #endif
37
38 #ifdef HAVE_SYS_SOCKET_H
39 #include <sys/socket.h>
40 #endif
41 #include <stdio.h>
42 #ifdef HAVE_MEMORY_H
43 #include <memory.h>
44 #endif
45
46 #define logfile curl_debuglogfile
47
48 extern FILE *logfile;
49
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);
58
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);
64
65 /* FILE functions */
66 FILE *curl_fopen(const char *file, const char *mode, int line,
67                  const char *source);
68 int curl_fclose(FILE *file, int line, const char *source);
69
70 #ifndef MEMDEBUG_NODEFINES
71
72 /* Set this symbol on the command-line, recompile all lib-sources */
73 #undef strdup
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__)
79
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__)
85
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__)
90
91 /* sclose is probably already defined, redefine it! */
92 #undef sclose
93 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
94 /* ares-adjusted define: */
95 #undef closesocket
96 #define closesocket(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
97
98 #undef fopen
99 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
100 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
101
102 #endif /* MEMDEBUG_NODEFINES */
103
104 #endif /* _CURL_MEDEBUG_H */
105 #endif /* CURLDEBUG */