Planeshift

DetourAlloc.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2009-2010 Mikko Mononen [email protected]
00003 //
00004 // This software is provided 'as-is', without any express or implied
00005 // warranty.  In no event will the authors be held liable for any damages
00006 // arising from the use of this software.
00007 // Permission is granted to anyone to use this software for any purpose,
00008 // including commercial applications, and to alter it and redistribute it
00009 // freely, subject to the following restrictions:
00010 // 1. The origin of this software must not be misrepresented; you must not
00011 //    claim that you wrote the original software. If you use this software
00012 //    in a product, an acknowledgment in the product documentation would be
00013 //    appreciated but is not required.
00014 // 2. Altered source versions must be plainly marked as such, and must not be
00015 //    misrepresented as being the original software.
00016 // 3. This notice may not be removed or altered from any source distribution.
00017 //
00018 
00019 #ifndef DETOURALLOCATOR_H
00020 #define DETOURALLOCATOR_H
00021 
00024 enum dtAllocHint
00025 {
00026         DT_ALLOC_PERM,          
00027         DT_ALLOC_TEMP           
00028 };
00029 
00031 //  @param[in]          size                    The size, in bytes of memory, to allocate.
00032 //  @param[in]          rcAllocHint     A hint to the allocator on how long the memory is expected to be in use.
00033 //  @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
00035 typedef void* (dtAllocFunc)(int size, dtAllocHint hint);
00036 
00040 typedef void (dtFreeFunc)(void* ptr);
00041 
00045 void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc);
00046 
00052 void* dtAlloc(int size, dtAllocHint hint);
00053 
00057 void dtFree(void* ptr);
00058 
00059 #endif