Unverified Commit 76b63489 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

memdebug: make debug-specific functions use curl_dbg_ prefix

To not "collide" or use up the regular curl_ name space. Also makes them
easier to detect in helper scripts.

Closes #3656
parent 50afa478
Loading
Loading
Loading
Loading
+16 −16
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -539,7 +539,7 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract)
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) &&  \
  defined(HAVE_FREEADDRINFO)
/*
 * curl_dofreeaddrinfo()
 * curl_dbg_freeaddrinfo()
 *
 * This is strictly for memory tracing and are using the same style as the
 * family otherwise present in memdebug.c. I put these ones here since they
@@ -547,7 +547,7 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract)
 */

void
curl_dofreeaddrinfo(struct addrinfo *freethis,
curl_dbg_freeaddrinfo(struct addrinfo *freethis,
                      int line, const char *source)
{
#ifdef USE_LWIPSOCK
@@ -555,7 +555,7 @@ curl_dofreeaddrinfo(struct addrinfo *freethis,
#else
  (freeaddrinfo)(freethis);
#endif
  curl_memlog("ADDR %s:%d freeaddrinfo(%p)\n",
  curl_dbg_log("ADDR %s:%d freeaddrinfo(%p)\n",
               source, line, (void *)freethis);
}
#endif /* defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) */
@@ -563,7 +563,7 @@ curl_dofreeaddrinfo(struct addrinfo *freethis,

#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
/*
 * curl_dogetaddrinfo()
 * curl_dbg_getaddrinfo()
 *
 * This is strictly for memory tracing and are using the same style as the
 * family otherwise present in memdebug.c. I put these ones here since they
@@ -571,7 +571,7 @@ curl_dofreeaddrinfo(struct addrinfo *freethis,
 */

int
curl_dogetaddrinfo(const char *hostname,
curl_dbg_getaddrinfo(const char *hostname,
                    const char *service,
                    const struct addrinfo *hints,
                    struct addrinfo **result,
@@ -584,10 +584,10 @@ curl_dogetaddrinfo(const char *hostname,
#endif
  if(0 == res)
    /* success */
    curl_memlog("ADDR %s:%d getaddrinfo() = %p\n",
    curl_dbg_log("ADDR %s:%d getaddrinfo() = %p\n",
                 source, line, (void *)*result);
  else
    curl_memlog("ADDR %s:%d getaddrinfo() failed\n",
    curl_dbg_log("ADDR %s:%d getaddrinfo() failed\n",
                 source, line);
  return res;
}
+5 −8
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -86,16 +86,13 @@ Curl_addrinfo *Curl_unix2addr(const char *path, bool *longpath, bool abstract);
#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) && \
    defined(HAVE_FREEADDRINFO)
void
curl_dofreeaddrinfo(struct addrinfo *freethis,
                    int line, const char *source);
curl_dbg_freeaddrinfo(struct addrinfo *freethis, int line, const char *source);
#endif

#if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO)
int
curl_dogetaddrinfo(const char *hostname,
                   const char *service,
                   const struct addrinfo *hints,
                   struct addrinfo **result,
curl_dbg_getaddrinfo(const char *hostname, const char *service,
                     const struct addrinfo *hints, struct addrinfo **result,
                     int line, const char *source);
#endif

+61 −62
Original line number Diff line number Diff line
@@ -100,19 +100,18 @@ struct memdebug {
 * Don't use these with multithreaded test programs!
 */

#define logfile curl_debuglogfile
FILE *curl_debuglogfile = NULL;
FILE *curl_dbg_logfile = NULL;
static bool memlimit = FALSE; /* enable memory limit */
static long memsize = 0;  /* set number of mallocs allowed */

/* this sets the log file name */
void curl_memdebug(const char *logname)
void curl_dbg_memdebug(const char *logname)
{
  if(!logfile) {
  if(!curl_dbg_logfile) {
    if(logname && *logname)
      logfile = fopen(logname, FOPEN_WRITETEXT);
      curl_dbg_logfile = fopen(logname, FOPEN_WRITETEXT);
    else
      logfile = stderr;
      curl_dbg_logfile = stderr;
#ifdef MEMDEBUG_LOG_SYNC
    /* Flush the log file after every line so the log isn't lost in a crash */
    if(logfile)
@@ -123,7 +122,7 @@ void curl_memdebug(const char *logname)

/* This function sets the number of malloc() calls that should return
   successfully! */
void curl_memlimit(long limit)
void curl_dbg_memlimit(long limit)
{
  if(!memlimit) {
    memlimit = TRUE;
@@ -140,12 +139,12 @@ static bool countcheck(const char *func, int line, const char *source)
    if(!memsize) {
      if(source) {
        /* log to file */
        curl_memlog("LIMIT %s:%d %s reached memlimit\n",
        curl_dbg_log("LIMIT %s:%d %s reached memlimit\n",
                     source, line, func);
        /* log to stderr also */
        fprintf(stderr, "LIMIT %s:%d %s reached memlimit\n",
                source, line, func);
        fflush(logfile); /* because it might crash now */
        fflush(curl_dbg_logfile); /* because it might crash now */
      }
      errno = ENOMEM;
      return TRUE; /* RETURN ERROR! */
@@ -159,7 +158,7 @@ static bool countcheck(const char *func, int line, const char *source)
  return FALSE; /* allow this */
}

void *curl_domalloc(size_t wantedsize, int line, const char *source)
void *curl_dbg_malloc(size_t wantedsize, int line, const char *source)
{
  struct memdebug *mem;
  size_t size;
@@ -180,14 +179,14 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source)
  }

  if(source)
    curl_memlog("MEM %s:%d malloc(%zu) = %p\n",
    curl_dbg_log("MEM %s:%d malloc(%zu) = %p\n",
                 source, line, wantedsize,
                 mem ? (void *)mem->mem : (void *)0);

  return (mem ? mem->mem : NULL);
}

void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
void *curl_dbg_calloc(size_t wanted_elements, size_t wanted_size,
                      int line, const char *source)
{
  struct memdebug *mem;
@@ -208,14 +207,14 @@ void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
    mem->size = user_size;

  if(source)
    curl_memlog("MEM %s:%d calloc(%zu,%zu) = %p\n",
    curl_dbg_log("MEM %s:%d calloc(%zu,%zu) = %p\n",
                 source, line, wanted_elements, wanted_size,
                 mem ? (void *)mem->mem : (void *)0);

  return (mem ? mem->mem : NULL);
}

char *curl_dostrdup(const char *str, int line, const char *source)
char *curl_dbg_strdup(const char *str, int line, const char *source)
{
  char *mem;
  size_t len;
@@ -227,19 +226,19 @@ char *curl_dostrdup(const char *str, int line, const char *source)

  len = strlen(str) + 1;

  mem = curl_domalloc(len, 0, NULL); /* NULL prevents logging */
  mem = curl_dbg_malloc(len, 0, NULL); /* NULL prevents logging */
  if(mem)
    memcpy(mem, str, len);

  if(source)
    curl_memlog("MEM %s:%d strdup(%p) (%zu) = %p\n",
    curl_dbg_log("MEM %s:%d strdup(%p) (%zu) = %p\n",
                 source, line, (const void *)str, len, (const void *)mem);

  return mem;
}

#if defined(WIN32) && defined(UNICODE)
wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
wchar_t *curl_dbg_wcsdup(const wchar_t *str, int line, const char *source)
{
  wchar_t *mem;
  size_t wsiz, bsiz;
@@ -252,12 +251,12 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
  wsiz = wcslen(str) + 1;
  bsiz = wsiz * sizeof(wchar_t);

  mem = curl_domalloc(bsiz, 0, NULL); /* NULL prevents logging */
  mem = curl_dbg_malloc(bsiz, 0, NULL); /* NULL prevents logging */
  if(mem)
    memcpy(mem, str, bsiz);

  if(source)
    curl_memlog("MEM %s:%d wcsdup(%p) (%zu) = %p\n",
    curl_dbg_log("MEM %s:%d wcsdup(%p) (%zu) = %p\n",
                source, line, (void *)str, bsiz, (void *)mem);

  return mem;
@@ -266,7 +265,7 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)

/* We provide a realloc() that accepts a NULL as pointer, which then
   performs a malloc(). In order to work with ares. */
void *curl_dorealloc(void *ptr, size_t wantedsize,
void *curl_dbg_realloc(void *ptr, size_t wantedsize,
                      int line, const char *source)
{
  struct memdebug *mem = NULL;
@@ -293,7 +292,7 @@ void *curl_dorealloc(void *ptr, size_t wantedsize,

  mem = (Curl_crealloc)(mem, size);
  if(source)
    curl_memlog("MEM %s:%d realloc(%p, %zu) = %p\n",
    curl_dbg_log("MEM %s:%d realloc(%p, %zu) = %p\n",
                source, line, (void *)ptr, wantedsize,
                mem ? (void *)mem->mem : (void *)0);

@@ -305,7 +304,7 @@ void *curl_dorealloc(void *ptr, size_t wantedsize,
  return NULL;
}

void curl_dofree(void *ptr, int line, const char *source)
void curl_dbg_free(void *ptr, int line, const char *source)
{
  struct memdebug *mem;

@@ -331,10 +330,10 @@ void curl_dofree(void *ptr, int line, const char *source)
  }

  if(source)
    curl_memlog("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
    curl_dbg_log("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
}

curl_socket_t curl_socket(int domain, int type, int protocol,
curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
                             int line, const char *source)
{
  const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
@@ -351,12 +350,12 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
  sockfd = socket(domain, type, protocol);

  if(source && (sockfd != CURL_SOCKET_BAD))
    curl_memlog(fmt, source, line, sockfd);
    curl_dbg_log(fmt, source, line, sockfd);

  return sockfd;
}

SEND_TYPE_RETV curl_dosend(SEND_TYPE_ARG1 sockfd,
SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
                            SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
                            SEND_TYPE_ARG3 len, SEND_TYPE_ARG4 flags, int line,
                            const char *source)
@@ -366,12 +365,12 @@ SEND_TYPE_RETV curl_dosend(SEND_TYPE_ARG1 sockfd,
    return -1;
  rc = send(sockfd, buf, len, flags);
  if(source)
    curl_memlog("SEND %s:%d send(%lu) = %ld\n",
    curl_dbg_log("SEND %s:%d send(%lu) = %ld\n",
                source, line, (unsigned long)len, (long)rc);
  return rc;
}

RECV_TYPE_RETV curl_dorecv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf,
RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf,
                            RECV_TYPE_ARG3 len, RECV_TYPE_ARG4 flags, int line,
                            const char *source)
{
@@ -380,13 +379,13 @@ RECV_TYPE_RETV curl_dorecv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf,
    return -1;
  rc = recv(sockfd, buf, len, flags);
  if(source)
    curl_memlog("RECV %s:%d recv(%lu) = %ld\n",
    curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n",
                source, line, (unsigned long)len, (long)rc);
  return rc;
}

#ifdef HAVE_SOCKETPAIR
int curl_socketpair(int domain, int type, int protocol,
int curl_dbg_socketpair(int domain, int type, int protocol,
                       curl_socket_t socket_vector[2],
                       int line, const char *source)
{
@@ -399,13 +398,13 @@ int curl_socketpair(int domain, int type, int protocol,
  int res = socketpair(domain, type, protocol, socket_vector);

  if(source && (0 == res))
    curl_memlog(fmt, source, line, socket_vector[0], socket_vector[1]);
    curl_dbg_log(fmt, source, line, socket_vector[0], socket_vector[1]);

  return res;
}
#endif

curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
curl_socket_t curl_dbg_accept(curl_socket_t s, void *saddr, void *saddrlen,
                             int line, const char *source)
{
  const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
@@ -420,13 +419,13 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
  curl_socket_t sockfd = accept(s, addr, addrlen);

  if(source && (sockfd != CURL_SOCKET_BAD))
    curl_memlog(fmt, source, line, sockfd);
    curl_dbg_log(fmt, source, line, sockfd);

  return sockfd;
}

/* separate function to allow libcurl to mark a "faked" close */
void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
void curl_dbg_mark_sclose(curl_socket_t sockfd, int line, const char *source)
{
  const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
    "FD %s:%d sclose(%d)\n":
@@ -435,30 +434,30 @@ void curl_mark_sclose(curl_socket_t sockfd, int line, const char *source)
    "FD %s:%d sclose(%zd)\n";

  if(source)
    curl_memlog(fmt, source, line, sockfd);
    curl_dbg_log(fmt, source, line, sockfd);
}

/* this is our own defined way to close sockets on *ALL* platforms */
int curl_sclose(curl_socket_t sockfd, int line, const char *source)
int curl_dbg_sclose(curl_socket_t sockfd, int line, const char *source)
{
  int res = sclose(sockfd);
  curl_mark_sclose(sockfd, line, source);
  curl_dbg_mark_sclose(sockfd, line, source);
  return res;
}

FILE *curl_fopen(const char *file, const char *mode,
FILE *curl_dbg_fopen(const char *file, const char *mode,
                    int line, const char *source)
{
  FILE *res = fopen(file, mode);

  if(source)
    curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
    curl_dbg_log("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
                source, line, file, mode, (void *)res);

  return res;
}

int curl_fclose(FILE *file, int line, const char *source)
int curl_dbg_fclose(FILE *file, int line, const char *source)
{
  int res;

@@ -467,7 +466,7 @@ int curl_fclose(FILE *file, int line, const char *source)
  res = fclose(file);

  if(source)
    curl_memlog("FILE %s:%d fclose(%p)\n",
    curl_dbg_log("FILE %s:%d fclose(%p)\n",
                source, line, (void *)file);

  return res;
@@ -476,13 +475,13 @@ int curl_fclose(FILE *file, int line, const char *source)
#define LOGLINE_BUFSIZE  1024

/* this does the writing to the memory tracking log file */
void curl_memlog(const char *format, ...)
void curl_dbg_log(const char *format, ...)
{
  char *buf;
  int nchars;
  va_list ap;

  if(!logfile)
  if(!curl_dbg_logfile)
    return;

  buf = (Curl_cmalloc)(LOGLINE_BUFSIZE);
@@ -497,7 +496,7 @@ void curl_memlog(const char *format, ...)
    nchars = LOGLINE_BUFSIZE - 1;

  if(nchars > 0)
    fwrite(buf, 1, (size_t)nchars, logfile);
    fwrite(buf, 1, (size_t)nchars, curl_dbg_logfile);

  (Curl_cfree)(buf);
}
+58 −59
Original line number Diff line number Diff line
@@ -30,93 +30,92 @@

#define CURL_MT_LOGFNAME_BUFSIZE 512

#define logfile curl_debuglogfile

extern FILE *logfile;
extern FILE *curl_dbg_logfile;

/* memory functions */
CURL_EXTERN void *curl_domalloc(size_t size, int line, const char *source);
CURL_EXTERN void *curl_docalloc(size_t elements, size_t size, int line,
CURL_EXTERN void *curl_dbg_malloc(size_t size, int line, const char *source);
CURL_EXTERN void *curl_dbg_calloc(size_t elements, size_t size, int line,
                                  const char *source);
CURL_EXTERN void *curl_dorealloc(void *ptr, size_t size, int line,
CURL_EXTERN void *curl_dbg_realloc(void *ptr, size_t size, int line,
                                   const char *source);
CURL_EXTERN void curl_dofree(void *ptr, int line, const char *source);
CURL_EXTERN char *curl_dostrdup(const char *str, int line, const char *source);
CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
CURL_EXTERN char *curl_dbg_strdup(const char *str, int line, const char *src);
#if defined(WIN32) && defined(UNICODE)
CURL_EXTERN wchar_t *curl_dowcsdup(const wchar_t *str, int line,
CURL_EXTERN wchar_t *curl_dbg_wcsdup(const wchar_t *str, int line,
                                     const char *source);
#endif

CURL_EXTERN void curl_memdebug(const char *logname);
CURL_EXTERN void curl_memlimit(long limit);
CURL_EXTERN void curl_memlog(const char *format, ...);
CURL_EXTERN void curl_dbg_memdebug(const char *logname);
CURL_EXTERN void curl_dbg_memlimit(long limit);
CURL_EXTERN void curl_dbg_log(const char *format, ...);

/* file descriptor manipulators */
CURL_EXTERN curl_socket_t curl_socket(int domain, int type, int protocol,
CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
                                          int line, const char *source);
CURL_EXTERN void curl_mark_sclose(curl_socket_t sockfd,
CURL_EXTERN void curl_dbg_mark_sclose(curl_socket_t sockfd,
                                      int line, const char *source);
CURL_EXTERN int curl_sclose(curl_socket_t sockfd,
CURL_EXTERN int curl_dbg_sclose(curl_socket_t sockfd,
                                int line, const char *source);
CURL_EXTERN curl_socket_t curl_accept(curl_socket_t s, void *a, void *alen,
CURL_EXTERN curl_socket_t curl_dbg_accept(curl_socket_t s, void *a, void *alen,
                                          int line, const char *source);
#ifdef HAVE_SOCKETPAIR
CURL_EXTERN int curl_socketpair(int domain, int type, int protocol,
CURL_EXTERN int curl_dbg_socketpair(int domain, int type, int protocol,
                                    curl_socket_t socket_vector[2],
                                    int line, const char *source);
#endif

/* send/receive sockets */
CURL_EXTERN SEND_TYPE_RETV curl_dosend(SEND_TYPE_ARG1 sockfd,
CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
                                         SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
                                         SEND_TYPE_ARG3 len,
                                         SEND_TYPE_ARG4 flags, int line,
                                         const char *source);
CURL_EXTERN RECV_TYPE_RETV curl_dorecv(RECV_TYPE_ARG1 sockfd,
                                       RECV_TYPE_ARG2 buf, RECV_TYPE_ARG3 len,
CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
                                         RECV_TYPE_ARG2 buf,
                                         RECV_TYPE_ARG3 len,
                                         RECV_TYPE_ARG4 flags, int line,
                                         const char *source);

/* FILE functions */
CURL_EXTERN FILE *curl_fopen(const char *file, const char *mode, int line,
CURL_EXTERN FILE *curl_dbg_fopen(const char *file, const char *mode, int line,
                                 const char *source);
CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);

#ifndef MEMDEBUG_NODEFINES

/* Set this symbol on the command-line, recompile all lib-sources */
#undef strdup
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
#define malloc(size) curl_domalloc(size, __LINE__, __FILE__)
#define calloc(nbelem,size) curl_docalloc(nbelem, size, __LINE__, __FILE__)
#define realloc(ptr,size) curl_dorealloc(ptr, size, __LINE__, __FILE__)
#define free(ptr) curl_dofree(ptr, __LINE__, __FILE__)
#define send(a,b,c,d) curl_dosend(a,b,c,d, __LINE__, __FILE__)
#define recv(a,b,c,d) curl_dorecv(a,b,c,d, __LINE__, __FILE__)
#define strdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
#define malloc(size) curl_dbg_malloc(size, __LINE__, __FILE__)
#define calloc(nbelem,size) curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
#define realloc(ptr,size) curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
#define free(ptr) curl_dbg_free(ptr, __LINE__, __FILE__)
#define send(a,b,c,d) curl_dbg_send(a,b,c,d, __LINE__, __FILE__)
#define recv(a,b,c,d) curl_dbg_recv(a,b,c,d, __LINE__, __FILE__)

#ifdef WIN32
#  ifdef UNICODE
#    undef wcsdup
#    define wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
#    define wcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
#    undef _wcsdup
#    define _wcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
#    define _wcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
#    undef _tcsdup
#    define _tcsdup(ptr) curl_dowcsdup(ptr, __LINE__, __FILE__)
#    define _tcsdup(ptr) curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
#  else
#    undef _tcsdup
#    define _tcsdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
#    define _tcsdup(ptr) curl_dbg_strdup(ptr, __LINE__, __FILE__)
#  endif
#endif

#undef socket
#define socket(domain,type,protocol)\
 curl_socket(domain, type, protocol, __LINE__, __FILE__)
 curl_dbg_socket(domain, type, protocol, __LINE__, __FILE__)
#undef accept /* for those with accept as a macro */
#define accept(sock,addr,len)\
 curl_accept(sock, addr, len, __LINE__, __FILE__)
 curl_dbg_accept(sock, addr, len, __LINE__, __FILE__)
#ifdef HAVE_SOCKETPAIR
#define socketpair(domain,type,protocol,socket_vector)\
 curl_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
 curl_dbg_socketpair(domain, type, protocol, socket_vector, __LINE__, __FILE__)
#endif

#ifdef HAVE_GETADDRINFO
@@ -125,31 +124,31 @@ CURL_EXTERN int curl_fclose(FILE *file, int line, const char *source);
   our macro as for other platforms. Instead, we redefine the new name they
   define getaddrinfo to become! */
#define ogetaddrinfo(host,serv,hint,res) \
  curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
  curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
#else
#undef getaddrinfo
#define getaddrinfo(host,serv,hint,res) \
  curl_dogetaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
  curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
#endif
#endif /* HAVE_GETADDRINFO */

#ifdef HAVE_FREEADDRINFO
#undef freeaddrinfo
#define freeaddrinfo(data) \
  curl_dofreeaddrinfo(data, __LINE__, __FILE__)
  curl_dbg_freeaddrinfo(data, __LINE__, __FILE__)
#endif /* HAVE_FREEADDRINFO */

/* sclose is probably already defined, redefine it! */
#undef sclose
#define sclose(sockfd) curl_sclose(sockfd,__LINE__,__FILE__)
#define sclose(sockfd) curl_dbg_sclose(sockfd,__LINE__,__FILE__)

#define fake_sclose(sockfd) curl_mark_sclose(sockfd,__LINE__,__FILE__)
#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd,__LINE__,__FILE__)

#undef fopen
#define fopen(file,mode) curl_fopen(file,mode,__LINE__,__FILE__)
#define fopen(file,mode) curl_dbg_fopen(file,mode,__LINE__,__FILE__)
#undef fdopen
#define fdopen(file,mode) curl_fdopen(file,mode,__LINE__,__FILE__)
#define fclose(file) curl_fclose(file,__LINE__,__FILE__)
#define fdopen(file,mode) curl_dbg_fdopen(file,mode,__LINE__,__FILE__)
#define fclose(file) curl_dbg_fclose(file,__LINE__,__FILE__)

#endif /* MEMDEBUG_NODEFINES */

+3 −16
Original line number Diff line number Diff line
@@ -145,22 +145,6 @@ my %api = (

    # the following funcions are provided globally in debug builds
    'curl_easy_perform_ev' => 'debug-build',
    'curl_memdebug' => 'debug-build',
    'curl_memlimit' => 'debug-build',
    'curl_memlog' => 'debug-build',
    'curl_accept' => 'debug-build',
    'curl_docalloc' => 'debug-build',
    'curl_dofree' => 'debug-build',
    'curl_domalloc' => 'debug-build',
    'curl_dorealloc' => 'debug-build',
    'curl_dorecv' => 'debug-build',
    'curl_dosend' => 'debug-build',
    'curl_dostrdup' => 'debug-build',
    'curl_fclose' => 'debug-build',
    'curl_fopen' => 'debug-build',
    'curl_sclose' => 'debug-build',
    'curl_socket' => 'debug-build',
    'curl_socketpair' => 'debug-build',
    );

open(N, "nm $file|") ||
@@ -202,6 +186,9 @@ for(sort keys %exist) {
                $err++;
            }
        }
        elsif($_ =~ /^curl_dbg_/) {
            # we ignore the memdebug symbols
        }
        elsif($wl{$_}) {
            #print "$_ is WL\n";
        }
Loading