Path: blob/master/thirdparty/recastnavigation/Recast/Source/RecastAlloc.cpp
9913 views
//1// Copyright (c) 2009-2010 Mikko Mononen [email protected]2//3// This software is provided 'as-is', without any express or implied4// warranty. In no event will the authors be held liable for any damages5// arising from the use of this software.6// Permission is granted to anyone to use this software for any purpose,7// including commercial applications, and to alter it and redistribute it8// freely, subject to the following restrictions:9// 1. The origin of this software must not be misrepresented; you must not10// claim that you wrote the original software. If you use this software11// in a product, an acknowledgment in the product documentation would be12// appreciated but is not required.13// 2. Altered source versions must be plainly marked as such, and must not be14// misrepresented as being the original software.15// 3. This notice may not be removed or altered from any source distribution.16//1718#include "RecastAlloc.h"1920static void* rcAllocDefault(size_t size, rcAllocHint)21{22return malloc(size);23}2425static void rcFreeDefault(void *ptr)26{27free(ptr);28}2930static rcAllocFunc* sRecastAllocFunc = rcAllocDefault;31static rcFreeFunc* sRecastFreeFunc = rcFreeDefault;3233void rcAllocSetCustom(rcAllocFunc* allocFunc, rcFreeFunc* freeFunc)34{35sRecastAllocFunc = allocFunc ? allocFunc : rcAllocDefault;36sRecastFreeFunc = freeFunc ? freeFunc : rcFreeDefault;37}3839void* rcAlloc(size_t size, rcAllocHint hint)40{41return sRecastAllocFunc(size, hint);42}4344void rcFree(void* ptr)45{46if (ptr != NULL)47{48sRecastFreeFunc(ptr);49}50}515253