Merge pull request #158 from recastnavigation/allocators-use-size-t
Use size_t for rcAlloc and dtAlloc
This commit is contained in:
commit
f8d6d3976d
@ -19,6 +19,8 @@
|
|||||||
#ifndef DETOURALLOCATOR_H
|
#ifndef DETOURALLOCATOR_H
|
||||||
#define DETOURALLOCATOR_H
|
#define DETOURALLOCATOR_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
/// Provides hint values to the memory allocator on how long the
|
/// Provides hint values to the memory allocator on how long the
|
||||||
/// memory is expected to be used.
|
/// memory is expected to be used.
|
||||||
enum dtAllocHint
|
enum dtAllocHint
|
||||||
@ -32,7 +34,7 @@ enum dtAllocHint
|
|||||||
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
||||||
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||||
/// @see dtAllocSetCustom
|
/// @see dtAllocSetCustom
|
||||||
typedef void* (dtAllocFunc)(int size, dtAllocHint hint);
|
typedef void* (dtAllocFunc)(size_t size, dtAllocHint hint);
|
||||||
|
|
||||||
/// A memory deallocation function.
|
/// A memory deallocation function.
|
||||||
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAllocFunc.
|
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAllocFunc.
|
||||||
@ -49,7 +51,7 @@ void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc);
|
|||||||
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
||||||
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||||
/// @see dtFree
|
/// @see dtFree
|
||||||
void* dtAlloc(int size, dtAllocHint hint);
|
void* dtAlloc(size_t size, dtAllocHint hint);
|
||||||
|
|
||||||
/// Deallocates a memory block.
|
/// Deallocates a memory block.
|
||||||
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAlloc.
|
/// @param[in] ptr A pointer to a memory block previously allocated using #dtAlloc.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "DetourAlloc.h"
|
#include "DetourAlloc.h"
|
||||||
|
|
||||||
static void *dtAllocDefault(int size, dtAllocHint)
|
static void *dtAllocDefault(size_t size, dtAllocHint)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc)
|
|||||||
sFreeFunc = freeFunc ? freeFunc : dtFreeDefault;
|
sFreeFunc = freeFunc ? freeFunc : dtFreeDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* dtAlloc(int size, dtAllocHint hint)
|
void* dtAlloc(size_t size, dtAllocHint hint)
|
||||||
{
|
{
|
||||||
return sAllocFunc(size, hint);
|
return sAllocFunc(size, hint);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ struct dtTileCacheAlloc
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* alloc(const int size)
|
virtual void* alloc(const size_t size)
|
||||||
{
|
{
|
||||||
return dtAlloc(size, DT_ALLOC_TEMP);
|
return dtAlloc(size, DT_ALLOC_TEMP);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#ifndef RECASTALLOC_H
|
#ifndef RECASTALLOC_H
|
||||||
#define RECASTALLOC_H
|
#define RECASTALLOC_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
/// Provides hint values to the memory allocator on how long the
|
/// Provides hint values to the memory allocator on how long the
|
||||||
/// memory is expected to be used.
|
/// memory is expected to be used.
|
||||||
enum rcAllocHint
|
enum rcAllocHint
|
||||||
@ -32,7 +34,7 @@ enum rcAllocHint
|
|||||||
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
// @param[in] rcAllocHint A hint to the allocator on how long the memory is expected to be in use.
|
||||||
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||||
/// @see rcAllocSetCustom
|
/// @see rcAllocSetCustom
|
||||||
typedef void* (rcAllocFunc)(int size, rcAllocHint hint);
|
typedef void* (rcAllocFunc)(size_t size, rcAllocHint hint);
|
||||||
|
|
||||||
/// A memory deallocation function.
|
/// A memory deallocation function.
|
||||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAllocFunc.
|
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAllocFunc.
|
||||||
@ -49,7 +51,7 @@ void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc);
|
|||||||
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
/// @param[in] hint A hint to the allocator on how long the memory is expected to be in use.
|
||||||
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
/// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed.
|
||||||
/// @see rcFree
|
/// @see rcFree
|
||||||
void* rcAlloc(int size, rcAllocHint hint);
|
void* rcAlloc(size_t size, rcAllocHint hint);
|
||||||
|
|
||||||
/// Deallocates a memory block.
|
/// Deallocates a memory block.
|
||||||
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAlloc.
|
/// @param[in] ptr A pointer to a memory block previously allocated using #rcAlloc.
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "RecastAlloc.h"
|
#include "RecastAlloc.h"
|
||||||
|
|
||||||
static void *rcAllocDefault(int size, rcAllocHint)
|
static void *rcAllocDefault(size_t size, rcAllocHint)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @see rcAllocSetCustom
|
/// @see rcAllocSetCustom
|
||||||
void* rcAlloc(int size, rcAllocHint hint)
|
void* rcAlloc(size_t size, rcAllocHint hint)
|
||||||
{
|
{
|
||||||
return sRecastAllocFunc(size, hint);
|
return sRecastAllocFunc(size, hint);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user