From b05e45492e06a7c79f3877b949f1a68acb73e2eb Mon Sep 17 00:00:00 2001 From: Sander van Noort Date: Sun, 3 Apr 2016 22:39:33 +0200 Subject: [PATCH] Fix memory leak in LinearAllocator used by Sample_TempObstacles --- RecastDemo/Source/Sample_TempObstacles.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/RecastDemo/Source/Sample_TempObstacles.cpp b/RecastDemo/Source/Sample_TempObstacles.cpp index c523b7c..3d2919c 100644 --- a/RecastDemo/Source/Sample_TempObstacles.cpp +++ b/RecastDemo/Source/Sample_TempObstacles.cpp @@ -132,11 +132,11 @@ struct FastLZCompressor : public dtTileCacheCompressor struct LinearAllocator : public dtTileCacheAlloc { unsigned char* buffer; - int capacity; - int top; - int high; + size_t capacity; + size_t top; + size_t high; - LinearAllocator(const int cap) : buffer(0), capacity(0), top(0), high(0) + LinearAllocator(const size_t cap) : buffer(0), capacity(0), top(0), high(0) { resize(cap); } @@ -146,7 +146,7 @@ struct LinearAllocator : public dtTileCacheAlloc dtFree(buffer); } - void resize(const int cap) + void resize(const size_t cap) { if (buffer) dtFree(buffer); buffer = (unsigned char*)dtAlloc(cap, DT_ALLOC_PERM); @@ -159,7 +159,7 @@ struct LinearAllocator : public dtTileCacheAlloc top = 0; } - virtual void* alloc(const int size) + virtual void* alloc(const size_t size) { if (!buffer) return 0;