Warning, file /education/gcompris/external/qml-box2d/Box2D/Common/b2BlockAllocator.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_BLOCK_ALLOCATOR_H 0020 #define B2_BLOCK_ALLOCATOR_H 0021 0022 #include <Box2D/Common/b2Settings.h> 0023 0024 const int32 b2_chunkSize = 16 * 1024; 0025 const int32 b2_maxBlockSize = 640; 0026 const int32 b2_blockSizes = 14; 0027 const int32 b2_chunkArrayIncrement = 128; 0028 0029 struct b2Block; 0030 struct b2Chunk; 0031 0032 /// This is a small object allocator used for allocating small 0033 /// objects that persist for more than one time step. 0034 /// See: http://www.codeproject.com/useritems/Small_Block_Allocator.asp 0035 class b2BlockAllocator 0036 { 0037 public: 0038 b2BlockAllocator(); 0039 ~b2BlockAllocator(); 0040 0041 /// Allocate memory. This will use b2Alloc if the size is larger than b2_maxBlockSize. 0042 void* Allocate(int32 size); 0043 0044 /// Free memory. This will use b2Free if the size is larger than b2_maxBlockSize. 0045 void Free(void* p, int32 size); 0046 0047 void Clear(); 0048 0049 private: 0050 0051 b2Chunk* m_chunks; 0052 int32 m_chunkCount; 0053 int32 m_chunkSpace; 0054 0055 b2Block* m_freeLists[b2_blockSizes]; 0056 0057 static int32 s_blockSizes[b2_blockSizes]; 0058 static uint8 s_blockSizeLookup[b2_maxBlockSize + 1]; 0059 static bool s_blockSizeLookupInitialized; 0060 }; 0061 0062 #endif