Bug 435739 Poor performance of Firefox 3 with no X RENDER extension
[wine-gecko.git] / tools / leaky / libmalloc.h
blobd7d3010221e9e025eea8f8350b725d11fb9dd2cf
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is
17 * Netscape Communications Corporation.
18 * Portions created by the Initial Developer are Copyright (C) 1999
19 * the Initial Developer. All Rights Reserved.
21 * Contributor(s):
22 * Kipp E.B. Hickman <kipp@netscape.com> (original author)
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef libmalloc_h___
39 #define libmalloc_h___
41 #include <sys/types.h>
42 #include <malloc.h>
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 #include "config.h"
50 typedef unsigned long u_long;
52 // Format of a malloc log entry. This is what's written out to the
53 // "malloc-log" file.
54 struct malloc_log_entry {
55 u_long type;
56 u_long address;
57 u_long size;
58 u_long oldaddress;
59 u_long numpcs;
60 char* pcs[MAX_STACK_CRAWL];
63 // type's
64 #define malloc_log_malloc 0
65 #define malloc_log_realloc 1
66 #define malloc_log_free 2
67 #define malloc_log_new 3
68 #define malloc_log_delete 4
69 #define malloc_log_addref 5
70 #define malloc_log_release 6
72 // Format of a malloc map entry; after this struct is nameLen+1 bytes of
73 // name data.
74 struct malloc_map_entry {
75 u_long nameLen;
76 u_long address; // base address
79 // A method that can be called if you want to programmatically control
80 // the malloc logging. Note that you must link with the library to do
81 // this (or use dlsym after dynamically loading the library...)
82 extern u_long SetMallocFlags(u_long flags);
84 // The environment variable LIBMALLOC_LOG should be set to an integer
85 // value whose meaning is as follows:
87 // Enable logging
88 #define LIBMALLOC_LOG 0x1
90 // Don't free memory when set
91 #define LIBMALLOC_NOFREE 0x2
93 // Check heap for corruption after every malloc/free/realloc
94 #define LIBMALLOC_CHECK 0x4
96 // Log reference count calls (addref/release)
97 #define LIBMALLOC_LOG_RC 0x8
99 void __log_addref(void* p, int oldrc, int newrc);
100 void __log_release(void* p, int oldrc, int newrc);
102 #ifdef __cplusplus
103 } /* end of extern "C" */
104 #endif
106 #endif /* libmalloc_h___ */