updated source code boilerplate/header
[platform/upstream/curl.git] / lib / memdebug.h
1 #ifdef MALLOCDEBUG
2 /***************************************************************************
3  *                                  _   _ ____  _     
4  *  Project                     ___| | | |  _ \| |    
5  *                             / __| | | | |_) | |    
6  *                            | (__| |_| |  _ <| |___ 
7  *                             \___|\___/|_| \_\_____|
8  *
9  * Copyright (C) 1998 - 2002, 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 extern FILE *logfile;
40
41 /* memory functions */
42 void *curl_domalloc(size_t size, int line, const char *source);
43 void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
44 void curl_dofree(void *ptr, int line, const char *source);
45 char *curl_dostrdup(const char *str, int line, const char *source);
46 void curl_memdebug(const char *logname);
47
48 /* file descriptor manipulators */
49 int curl_socket(int domain, int type, int protocol, int, const char *);
50 int curl_sclose(int sockfd, int, const char *source);
51 int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
52                 int line, const char *source);
53
54 /* FILE functions */
55 FILE *curl_fopen(const char *file, const char *mode, int line,
56                  const char *source);
57 int curl_fclose(FILE *file, int line, const char *source);
58
59 /* Set this symbol on the command-line, recompile all lib-sources */
60 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
61 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
62 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
63 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
64
65 #define socket(domain,type,protocol)\
66  curl_socket(domain,type,protocol,__LINE__,__FILE__)
67 #define accept(sock,addr,len)\
68  curl_accept(sock,addr,len,__LINE__,__FILE__)
69
70 #define getaddrinfo(host,serv,hint,res) \
71   curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
72 #define freeaddrinfo(data) \
73   curl_freeaddrinfo(data,__LINE__,__FILE__)
74
75 /* sclose is probably already defined, redefine it! */
76 #undef sclose
77 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
78
79 #undef fopen
80 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
81 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
82
83 #endif