Nico's VMS adjustment
[platform/upstream/curl.git] / lib / memdebug.h
1 #ifdef MALLOCDEBUG
2
3 #include <sys/socket.h>
4 #include <stdio.h>
5 #ifdef HAVE_MEMORY_H
6 #include <memory.h>
7 #endif
8
9 /* memory functions */
10 void *curl_domalloc(size_t size, int line, char *source);
11 void *curl_dorealloc(void *ptr, size_t size, int line, char *source);
12 void curl_dofree(void *ptr, int line, char *source);
13 char *curl_dostrdup(const char *str, int line, char *source);
14 void curl_memdebug(char *logname);
15
16 /* file descriptor manipulators */
17 int curl_socket(int domain, int type, int protocol, int, char *);
18 int curl_sclose(int sockfd, int, char *);
19 int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
20                 int line, char *source);
21
22 /* FILE functions */
23 FILE *curl_fopen(char *file, char *mode, int line, char *source);
24 int curl_fclose(FILE *file, int line, char *source);
25
26 /* Set this symbol on the command-line, recompile all lib-sources */
27 #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
28 #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
29 #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
30 #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
31
32 #define socket(domain,type,protocol)\
33  curl_socket(domain,type,protocol,__LINE__,__FILE__)
34 #define accept(sock,addr,len)\
35  curl_accept(sock,addr,len,__LINE__,__FILE__)
36
37 /* sclose is probably already defined, redefine it! */
38 #undef sclose
39 #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
40
41 #undef fopen
42 #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
43 #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
44
45 #endif