From 551d1b250ead709c68a82255384223bad9d781f4 Mon Sep 17 00:00:00 2001 From: Ben Hymers Date: Fri, 15 Jan 2016 00:13:52 +0000 Subject: [PATCH] Use size_t for rcAlloc and dtAlloc This was already partly done by @cexikitin in #65, I'm just finishing it off in their absence! Closes #65 --- Detour/Include/DetourAlloc.h | 6 ++++-- Detour/Source/DetourAlloc.cpp | 4 ++-- DetourTileCache/Include/DetourTileCacheBuilder.h | 2 +- Recast/Include/RecastAlloc.h | 6 ++++-- Recast/Source/RecastAlloc.cpp | 4 ++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Detour/Include/DetourAlloc.h b/Detour/Include/DetourAlloc.h index e814b62..f87b454 100644 --- a/Detour/Include/DetourAlloc.h +++ b/Detour/Include/DetourAlloc.h @@ -19,6 +19,8 @@ #ifndef DETOURALLOCATOR_H #define DETOURALLOCATOR_H +#include + /// Provides hint values to the memory allocator on how long the /// memory is expected to be used. 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. // @return A pointer to the beginning of the allocated memory block, or null if the allocation failed. /// @see dtAllocSetCustom -typedef void* (dtAllocFunc)(int size, dtAllocHint hint); +typedef void* (dtAllocFunc)(size_t size, dtAllocHint hint); /// A memory deallocation function. /// @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. /// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed. /// @see dtFree -void* dtAlloc(int size, dtAllocHint hint); +void* dtAlloc(size_t size, dtAllocHint hint); /// Deallocates a memory block. /// @param[in] ptr A pointer to a memory block previously allocated using #dtAlloc. diff --git a/Detour/Source/DetourAlloc.cpp b/Detour/Source/DetourAlloc.cpp index 5f671df..d9ad1fc 100644 --- a/Detour/Source/DetourAlloc.cpp +++ b/Detour/Source/DetourAlloc.cpp @@ -19,7 +19,7 @@ #include #include "DetourAlloc.h" -static void *dtAllocDefault(int size, dtAllocHint) +static void *dtAllocDefault(size_t size, dtAllocHint) { return malloc(size); } @@ -38,7 +38,7 @@ void dtAllocSetCustom(dtAllocFunc *allocFunc, dtFreeFunc *freeFunc) sFreeFunc = freeFunc ? freeFunc : dtFreeDefault; } -void* dtAlloc(int size, dtAllocHint hint) +void* dtAlloc(size_t size, dtAllocHint hint) { return sAllocFunc(size, hint); } diff --git a/DetourTileCache/Include/DetourTileCacheBuilder.h b/DetourTileCache/Include/DetourTileCacheBuilder.h index 938d415..7e3b124 100644 --- a/DetourTileCache/Include/DetourTileCacheBuilder.h +++ b/DetourTileCache/Include/DetourTileCacheBuilder.h @@ -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); } diff --git a/Recast/Include/RecastAlloc.h b/Recast/Include/RecastAlloc.h index 500dea2..7e15735 100644 --- a/Recast/Include/RecastAlloc.h +++ b/Recast/Include/RecastAlloc.h @@ -19,6 +19,8 @@ #ifndef RECASTALLOC_H #define RECASTALLOC_H +#include + /// Provides hint values to the memory allocator on how long the /// memory is expected to be used. 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. // @return A pointer to the beginning of the allocated memory block, or null if the allocation failed. /// @see rcAllocSetCustom -typedef void* (rcAllocFunc)(int size, rcAllocHint hint); +typedef void* (rcAllocFunc)(size_t size, rcAllocHint hint); /// A memory deallocation function. /// @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. /// @return A pointer to the beginning of the allocated memory block, or null if the allocation failed. /// @see rcFree -void* rcAlloc(int size, rcAllocHint hint); +void* rcAlloc(size_t size, rcAllocHint hint); /// Deallocates a memory block. /// @param[in] ptr A pointer to a memory block previously allocated using #rcAlloc. diff --git a/Recast/Source/RecastAlloc.cpp b/Recast/Source/RecastAlloc.cpp index af843f7..ee1039f 100644 --- a/Recast/Source/RecastAlloc.cpp +++ b/Recast/Source/RecastAlloc.cpp @@ -20,7 +20,7 @@ #include #include "RecastAlloc.h" -static void *rcAllocDefault(int size, rcAllocHint) +static void *rcAllocDefault(size_t size, rcAllocHint) { return malloc(size); } @@ -41,7 +41,7 @@ void rcAllocSetCustom(rcAllocFunc *allocFunc, rcFreeFunc *freeFunc) } /// @see rcAllocSetCustom -void* rcAlloc(int size, rcAllocHint hint) +void* rcAlloc(size_t size, rcAllocHint hint) { return sRecastAllocFunc(size, hint); }