updated year in the copyright string
[platform/upstream/curl.git] / lib / memdebug.h
1 #ifdef CURLDEBUG
2 /***************************************************************************
3  *                                  _   _ ____  _     
4  *  Project                     ___| | | |  _ \| |    
5  *                             / __| | | | |_) | |    
6  *                            | (__| |_| |  _ <| |___ 
7  *                             \___|\___/|_| \_\_____|
8  *
9  * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
10  *
11  * This software is licensed as described in the file COPYING, which
12  * you should have received as part of this distribution. The terms
13  * are also available at http://curl.haxx.se/docs/copyright.html.
14  * 
15  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
16  * copies of the Software, and permit persons to whom the Software is
17  * furnished to do so, under the terms of the COPYING file.
18  *
19  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20  * KIND, either express or implied.
21  *
22  * $Id$
23  ***************************************************************************/
24
25 #include "setup.h"
26
27 #ifdef HAVE_SYS_TYPES_H
28 #include <sys/types.h>
29 #endif
30
31 #ifdef HAVE_SYS_SOCKET_H
32 #include <sys/socket.h>
33 #endif
34 #include <stdio.h>
35 #ifdef HAVE_MEMORY_H
36 #include <memory.h>
37 #endif
38
39 #define logfile curl_debuglogfile
40
41 extern FILE *logfile;
42
43 /* memory functions */
44 void *curl_domalloc(size_t size, int line, const char *source);
45 void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
46 void curl_dofree(void *ptr, int line, const char *source);
47 char *curl_dostrdup(const char *str, int line, const char *source);
48 void curl_memdebug(const char *logname);
49 void curl_memlimit(long limit);
50
51 /* file descriptor manipulators */
52 int curl_socket(int domain, int type, int protocol, int, const char *);
53 int curl_sclose(int sockfd, int, const char *source);
54 int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
55                 int line, const char *source);
56
57 /* FILE functions */
58 FILE *curl_fopen(const char *file, const char *mode, int line,
59                  const char *source);
60 int curl_fclose(FILE *file, int line, const char *source);
61
62 /* Set this symbol on the command-line, recompile all lib-sources */
63 #undef strdup
64 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
65 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
66 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
67 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
68
69 #define socket(domain,type,protocol)\
70  curl_socket(domain,type,protocol,__LINE__,__FILE__)
71 #define accept(sock,addr,len)\
72  curl_accept(sock,addr,len,__LINE__,__FILE__)
73
74 #define getaddrinfo(host,serv,hint,res) \
75   curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
76 #define freeaddrinfo(data) \
77   curl_freeaddrinfo(data,__LINE__,__FILE__)
78
79 /* sclose is probably already defined, redefine it! */
80 #undef sclose
81 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
82
83 #undef fopen
84 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
85 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
86
87 #endif