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
14 * The Original Code is mozilla.org code.
16 * The Initial Developer of the Original Code is Kipp E.B. Hickman.
17 * Portions created by the Initial Developer are Copyright (C) 1998
18 * the Initial Developer. All Rights Reserved.
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 2 or later (the "GPL"), or
24 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25 * in which case the provisions of the GPL or the LGPL are applicable instead
26 * of those above. If you wish to allow use of your version of this file only
27 * under the terms of either the GPL or the LGPL, and not to allow others to
28 * use your version of this file under the terms of the MPL, indicate your
29 * decision by deleting the provisions above and replace them with the notice
30 * and other provisions required by the GPL or the LGPL. If you do not delete
31 * the provisions above, a recipient may use your version of this file under
32 * the terms of any one of the MPL, the GPL or the LGPL.
34 * ***** END LICENSE BLOCK ***** */
36 #ifndef libmalloc_h___
37 #define libmalloc_h___
39 #include <sys/types.h>
48 typedef unsigned long u_long
;
50 // Format of a malloc log entry. This is what's written out to the
52 struct malloc_log_entry
{
55 char* pcs
[MAX_STACK_CRAWL
];
59 #define malloc_log_stack 7
61 // Format of a malloc map entry; after this struct is nameLen+1 bytes of
63 struct malloc_map_entry
{
65 u_long address
; // base address
68 // A method that can be called if you want to programmatically control
69 // the malloc logging. Note that you must link with the library to do
70 // this (or use dlsym after dynamically loading the library...)
71 extern u_long
SetMallocFlags(u_long flags
);
73 // The environment variable LIBMALLOC_LOG should be set to an integer
74 // value whose meaning is as follows:
77 #define LIBMALLOC_LOG 0x1
79 // Don't free memory when set
80 #define LIBMALLOC_NOFREE 0x2
82 // Check heap for corruption after every malloc/free/realloc
83 #define LIBMALLOC_CHECK 0x4
85 // Log reference count calls (addref/release)
86 #define LIBMALLOC_LOG_RC 0x8
89 #define LIBMALLOC_LOG_TRACE 0x10
91 void __log_addref(void* p
, int oldrc
, int newrc
);
92 void __log_release(void* p
, int oldrc
, int newrc
);
95 } /* end of extern "C" */
98 #endif /* libmalloc_h___ */