~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/memdebug.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2007, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: memdebug.c,v 1.56 2008-05-14 23:36:26 danf Exp $
 
21
 * $Id: memdebug.c,v 1.60 2008-10-23 08:05:40 danf Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
167
167
  }
168
168
 
169
169
  if(logfile && source)
170
 
    fprintf(logfile, "MEM %s:%d calloc(%u,%u) = %p\n",
 
170
    fprintf(logfile, "MEM %s:%d calloc(%zu,%zu) = %p\n",
171
171
            source, line, wanted_elements, wanted_size, mem ? mem->mem : 0);
172
172
  return (mem ? mem->mem : NULL);
173
173
}
189
189
    memcpy(mem, str, len);
190
190
 
191
191
  if(logfile)
192
 
    fprintf(logfile, "MEM %s:%d strdup(%p) (%zd) = %p\n",
 
192
    fprintf(logfile, "MEM %s:%d strdup(%p) (%zu) = %p\n",
193
193
            source, line, str, len, mem);
194
194
 
195
195
  return mem;
212
212
 
213
213
  mem=(struct memdebug *)(Curl_crealloc)(mem, size);
214
214
  if(logfile)
215
 
    fprintf(logfile, "MEM %s:%d realloc(%p, %zd) = %p\n",
 
215
    fprintf(logfile, "MEM %s:%d realloc(%p, %zu) = %p\n",
216
216
            source, line, ptr, wantedsize, mem?mem->mem:NULL);
217
217
 
218
218
  if(mem) {
244
244
int curl_socket(int domain, int type, int protocol, int line,
245
245
                const char *source)
246
246
{
247
 
  int sockfd=(socket)(domain, type, protocol);
 
247
  int sockfd=socket(domain, type, protocol);
248
248
  if(logfile && (sockfd!=-1))
249
249
    fprintf(logfile, "FD %s:%d socket() = %d\n",
250
250
            source, line, sockfd);
256
256
{
257
257
  struct sockaddr *addr = (struct sockaddr *)saddr;
258
258
  socklen_t *addrlen = (socklen_t *)saddrlen;
259
 
  int sockfd=(accept)(s, addr, addrlen);
 
259
  int sockfd=accept(s, addr, addrlen);
260
260
  if(logfile)
261
261
    fprintf(logfile, "FD %s:%d accept() = %d\n",
262
262
            source, line, sockfd);
276
276
FILE *curl_fopen(const char *file, const char *mode,
277
277
                 int line, const char *source)
278
278
{
279
 
  FILE *res=(fopen)(file, mode);
 
279
  FILE *res=fopen(file, mode);
280
280
  if(logfile)
281
281
    fprintf(logfile, "FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
282
282
            source, line, file, mode, res);
283
283
  return res;
284
284
}
285
285
 
 
286
#ifdef HAVE_FDOPEN
286
287
FILE *curl_fdopen(int filedes, const char *mode,
287
288
                  int line, const char *source)
288
289
{
289
 
  FILE *res=(fdopen)(filedes, mode);
 
290
  FILE *res=fdopen(filedes, mode);
290
291
  if(logfile)
291
292
    fprintf(logfile, "FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
292
293
            source, line, filedes, mode, res);
293
294
  return res;
294
295
}
 
296
#endif
295
297
 
296
298
int curl_fclose(FILE *file, int line, const char *source)
297
299
{
299
301
 
300
302
  DEBUGASSERT(file != NULL);
301
303
 
302
 
  res=(fclose)(file);
 
304
  res=fclose(file);
303
305
  if(logfile)
304
306
    fprintf(logfile, "FILE %s:%d fclose(%p)\n",
305
307
            source, line, file);
306
308
  return res;
307
309
}
308
 
#else
309
 
#ifdef VMS
310
 
int VOID_VAR_MEMDEBUG;
311
 
#else
312
 
/* we provide a fake do-nothing function here to avoid compiler warnings */
313
 
void curl_memdebug(void) {}
314
 
#endif /* VMS */
315
310
#endif /* CURLDEBUG */