/usr/include/opencollada/GeneratedSaxParser/GeneratedSaxParserStackMemoryManager.h is in opencollada-dev 0.1.0~20140703.ddf8f47+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | /*
Copyright (c) 2008-2009 NetAllied Systems GmbH
This file is part of GeneratedSaxParser.
Licensed under the MIT Open Source License,
for details please see LICENSE file or the website
http://www.opensource.org/licenses/mit-license.php
*/
#ifndef __GENERATEDSAXPARSER_STACKMEMORYMANAGER_H__
#define __GENERATEDSAXPARSER_STACKMEMORYMANAGER_H__
#include "GeneratedSaxParserPrerequisites.h"
namespace GeneratedSaxParser
{
/** Memory manager that implements a stack.
Memory fragmentation:
______________ _ ______________ _ ______________ _
| | | | | | |
-------------- - -------------- - -------------- -
data0 size0 data1 size1 data2 size2
*/
class StackMemoryManager
{
private:
static const size_t MAX_NUM_OF_FRAMES = 12;
static const size_t SIZE_OF_NEW_FRAME_FACTOR = 2;
struct StackFrame
{
StackFrame() : mCurrentPosition(0), mMaxMemoryBlob(0), mMemoryBlob(0)
{}
StackFrame(size_t size, char* memoryBlob) :
mCurrentPosition(0),
mMaxMemoryBlob(size),
mMemoryBlob(memoryBlob)
{}
/**
* Points at beginning of free space inside mMemoryBlob.
* Or in other words: points after size of top object.
*/
size_t mCurrentPosition;
/** Size of mMemoryBlob. */
size_t mMaxMemoryBlob;
/** Pointer to allocated memory. */
char* mMemoryBlob;
};
size_t mActiveFrame;
StackFrame* mFrames;
public:
StackMemoryManager(size_t stackSize);
~StackMemoryManager();
void* newObject(size_t objectSize);
void deleteObject();
void* growObject(size_t amount);
/** Returns ptr to top object on stack or 0 when stack is empty. Object will not be removed. */
void* top();
protected:
inline size_t getTopObjectSize();
inline void writeNewObjectSize(size_t position, size_t size);
bool allocateMoreMemory();
private:
/** Disable default copy ctor. */
StackMemoryManager( const StackMemoryManager& pre );
/** Disable default assignment operator. */
const StackMemoryManager& operator= ( const StackMemoryManager& pre );
};
} // namespace GeneratedSaxParser
#endif // __GENERATEDSAXPARSER_STACKMEMORYMANAGER_H__
|