Warning, file /education/gcompris/external/qml-box2d/Box2D/Common/b2StackAllocator.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002 * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
0003 *
0004 * This software is provided 'as-is', without any express or implied
0005 * warranty.  In no event will the authors be held liable for any damages
0006 * arising from the use of this software.
0007 * Permission is granted to anyone to use this software for any purpose,
0008 * including commercial applications, and to alter it and redistribute it
0009 * freely, subject to the following restrictions:
0010 * 1. The origin of this software must not be misrepresented; you must not
0011 * claim that you wrote the original software. If you use this software
0012 * in a product, an acknowledgment in the product documentation would be
0013 * appreciated but is not required.
0014 * 2. Altered source versions must be plainly marked as such, and must not be
0015 * misrepresented as being the original software.
0016 * 3. This notice may not be removed or altered from any source distribution.
0017 */
0018 
0019 #ifndef B2_STACK_ALLOCATOR_H
0020 #define B2_STACK_ALLOCATOR_H
0021 
0022 #include <Box2D/Common/b2Settings.h>
0023 
0024 const int32 b2_stackSize = 100 * 1024;  // 100k
0025 const int32 b2_maxStackEntries = 32;
0026 
0027 struct b2StackEntry
0028 {
0029     char* data;
0030     int32 size;
0031     bool usedMalloc;
0032 };
0033 
0034 // This is a stack allocator used for fast per step allocations.
0035 // You must nest allocate/free pairs. The code will assert
0036 // if you try to interleave multiple allocate/free pairs.
0037 class b2StackAllocator
0038 {
0039 public:
0040     b2StackAllocator();
0041     ~b2StackAllocator();
0042 
0043     void* Allocate(int32 size);
0044     void Free(void* p);
0045 
0046     int32 GetMaxAllocation() const;
0047 
0048 private:
0049 
0050     char m_data[b2_stackSize];
0051     int32 m_index;
0052 
0053     int32 m_allocation;
0054     int32 m_maxAllocation;
0055 
0056     b2StackEntry m_entries[b2_maxStackEntries];
0057     int32 m_entryCount;
0058 };
0059 
0060 #endif