Merge mozilla-central and tracemonkey. (a=blockers)
[mozilla-central.git] / layout / base / nsPresArena.h
blob46a1f2d96fe8175e9782d335f734b4b704eff0ef
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=2 sw=2 et tw=78:
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Steve Clark <buster@netscape.com>
25 * HÃ¥kan Waara <hwaara@chello.se>
26 * Dan Rosen <dr@netscape.com>
27 * Daniel Glazman <glazman@netscape.com>
28 * Mats Palmgren <mats.palmgren@bredband.net>
30 * Alternatively, the contents of this file may be used under the terms of
31 * either of the GNU General Public License Version 2 or later (the "GPL"),
32 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
33 * in which case the provisions of the GPL or the LGPL are applicable instead
34 * of those above. If you wish to allow use of your version of this file only
35 * under the terms of either the GPL or the LGPL, and not to allow others to
36 * use your version of this file under the terms of the MPL, indicate your
37 * decision by deleting the provisions above and replace them with the notice
38 * and other provisions required by the GPL or the LGPL. If you do not delete
39 * the provisions above, a recipient may use your version of this file under
40 * the terms of any one of the MPL, the GPL or the LGPL.
42 * ***** END LICENSE BLOCK *****
45 #ifndef nsPresArena_h___
46 #define nsPresArena_h___
48 #include "nscore.h"
49 #include "nsQueryFrame.h"
51 // Uncomment this to disable arenas, instead forwarding to
52 // malloc for every allocation.
53 //#define DEBUG_TRACEMALLOC_PRESARENA 1
55 // The debugging version of nsPresArena does not free all the memory it
56 // allocated when the arena itself is destroyed.
57 #ifdef DEBUG_TRACEMALLOC_PRESARENA
58 #define PRESARENA_MUST_FREE_DURING_DESTROY PR_TRUE
59 #else
60 #define PRESARENA_MUST_FREE_DURING_DESTROY PR_FALSE
61 #endif
63 class nsPresArena {
64 public:
65 nsPresArena();
66 ~nsPresArena();
68 // Pool allocation with recycler lists indexed by object size.
69 NS_HIDDEN_(void*) AllocateBySize(size_t aSize);
70 NS_HIDDEN_(void) FreeBySize(size_t aSize, void* aPtr);
72 // Pool allocation with recycler lists indexed by object-type code.
73 // Every type code must always be used with the same object size.
74 NS_HIDDEN_(void*) AllocateByCode(nsQueryFrame::FrameIID aCode, size_t aSize);
75 NS_HIDDEN_(void) FreeByCode(nsQueryFrame::FrameIID aCode, void* aPtr);
77 PRUint32 Size();
79 private:
80 struct State;
81 State* mState;
84 #endif