Skip to content

Commit b05e454

Browse files
Sandernjakobbotsch
authored andcommitted
Fix memory leak in LinearAllocator used by Sample_TempObstacles
1 parent d718702 commit b05e454

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

RecastDemo/Source/Sample_TempObstacles.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ struct FastLZCompressor : public dtTileCacheCompressor
132132
struct LinearAllocator : public dtTileCacheAlloc
133133
{
134134
unsigned char* buffer;
135-
int capacity;
136-
int top;
137-
int high;
135+
size_t capacity;
136+
size_t top;
137+
size_t high;
138138

139-
LinearAllocator(const int cap) : buffer(0), capacity(0), top(0), high(0)
139+
LinearAllocator(const size_t cap) : buffer(0), capacity(0), top(0), high(0)
140140
{
141141
resize(cap);
142142
}
@@ -146,7 +146,7 @@ struct LinearAllocator : public dtTileCacheAlloc
146146
dtFree(buffer);
147147
}
148148

149-
void resize(const int cap)
149+
void resize(const size_t cap)
150150
{
151151
if (buffer) dtFree(buffer);
152152
buffer = (unsigned char*)dtAlloc(cap, DT_ALLOC_PERM);
@@ -159,7 +159,7 @@ struct LinearAllocator : public dtTileCacheAlloc
159159
top = 0;
160160
}
161161

162-
virtual void* alloc(const int size)
162+
virtual void* alloc(const size_t size)
163163
{
164164
if (!buffer)
165165
return 0;

0 commit comments

Comments
 (0)