2 /*****************************************************************************
4 * Project ___| | | | _ \| |
6 * | (__| |_| | _ <| |___
7 * \___|\___/|_| \_\_____|
9 * The contents of this file are subject to the Mozilla Public License
10 * Version 1.0 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
16 * License for the specific language governing rights and limitations
19 * The Original Code is Curl.
21 * The Initial Developer of the Original Code is Daniel Stenberg.
23 * Portions created by the Initial Developer are Copyright (C) 1999.
24 * All Rights Reserved.
26 * ------------------------------------------------------------
28 * - Daniel Stenberg <daniel@haxx.se>
39 * ------------------------------------------------------------
40 ****************************************************************************/
44 #include <curl/curl.h>
50 * Note that these debug functions are very simple and they are meant to
51 * remain so. For advanced analysis, record a log file and write perl scripts
54 * Don't use these with multithreaded test programs!
59 /* this sets the log file name */
60 void curl_memdebug(char *logname)
62 logfile = fopen(logname, "w");
66 void *curl_domalloc(size_t size, int line, char *source)
68 void *mem=(malloc)(size);
69 fprintf(logfile, "MEM %s:%d malloc(%d) = %p\n",
70 source, line, size, mem);
74 char *curl_dostrdup(char *str, int line, char *source)
76 char *mem=(strdup)(str);
77 size_t len=strlen(str)+1;
78 fprintf(logfile, "MEM %s:%d strdup(%p) (%d) = %p\n",
79 source, line, str, len, mem);
83 void *curl_dorealloc(void *ptr, size_t size, int line, char *source)
85 void *mem=(realloc)(ptr, size);
86 fprintf(logfile, "MEM %s:%d realloc(%p, %d) = %p\n",
87 source, line, ptr, size, mem);
91 void curl_dofree(void *ptr, int line, char *source)
94 fprintf(logfile, "MEM %s:%d free(%p)\n",
98 #endif /* MALLOCDEBUG */