memdebug.h 1.9 KB

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