memdebug.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifdef MALLOCDEBUG
  2. /***************************************************************************
  3. * _ _ ____ _
  4. * Project ___| | | | _ \| |
  5. * / __| | | | |_) | |
  6. * | (__| |_| | _ <| |___
  7. * \___|\___/|_| \_\_____|
  8. *
  9. * Copyright (C) 1998 - 2002, Daniel Stenberg, <[email protected]>, 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. #include "setup.h"
  25. #ifdef HAVE_SYS_TYPES_H
  26. #include <sys/types.h>
  27. #endif
  28. #ifdef HAVE_SYS_SOCKET_H
  29. #include <sys/socket.h>
  30. #endif
  31. #include <stdio.h>
  32. #ifdef HAVE_MEMORY_H
  33. #include <memory.h>
  34. #endif
  35. extern FILE *logfile;
  36. /* memory functions */
  37. void *curl_domalloc(size_t size, int line, const char *source);
  38. void *curl_dorealloc(void *ptr, size_t size, int line, const char *source);
  39. void curl_dofree(void *ptr, int line, const char *source);
  40. char *curl_dostrdup(const char *str, int line, const char *source);
  41. void curl_memdebug(const char *logname);
  42. /* file descriptor manipulators */
  43. int curl_socket(int domain, int type, int protocol, int, const char *);
  44. int curl_sclose(int sockfd, int, const char *source);
  45. int curl_accept(int s, struct sockaddr *addr, socklen_t *addrlen,
  46. int line, const char *source);
  47. /* FILE functions */
  48. FILE *curl_fopen(const char *file, const char *mode, int line,
  49. const char *source);
  50. int curl_fclose(FILE *file, int line, const char *source);
  51. /* Set this symbol on the command-line, recompile all lib-sources */
  52. #undef strdup
  53. #define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
  54. #define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
  55. #define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
  56. #define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
  57. #define socket(domain,type,protocol)\
  58. curl_socket(domain,type,protocol,__LINE__,__FILE__)
  59. #define accept(sock,addr,len)\
  60. curl_accept(sock,addr,len,__LINE__,__FILE__)
  61. #define getaddrinfo(host,serv,hint,res) \
  62. curl_getaddrinfo(host,serv,hint,res,__LINE__,__FILE__)
  63. #define freeaddrinfo(data) \
  64. curl_freeaddrinfo(data,__LINE__,__FILE__)
  65. /* sclose is probably already defined, redefine it! */
  66. #undef sclose
  67. #define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
  68. #undef fopen
  69. #define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
  70. #define fclose(file) curl_fclose(file,__LINE__,__FILE__)
  71. #endif