mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-30 18:09:09 +00:00
(svn r15649) -Fix (r15556): don't unnecessarily reallocate
This commit is contained in:
@@ -102,6 +102,7 @@ public:
|
|||||||
if (this->count < count) {
|
if (this->count < count) {
|
||||||
free(this->buffer);
|
free(this->buffer);
|
||||||
this->buffer = MallocT<T>(count);
|
this->buffer = MallocT<T>(count);
|
||||||
|
this->count = count;
|
||||||
}
|
}
|
||||||
return this->buffer;
|
return this->buffer;
|
||||||
}
|
}
|
||||||
@@ -118,6 +119,7 @@ public:
|
|||||||
if (this->count < count) {
|
if (this->count < count) {
|
||||||
free(this->buffer);
|
free(this->buffer);
|
||||||
this->buffer = CallocT<T>(count);
|
this->buffer = CallocT<T>(count);
|
||||||
|
this->count = count;
|
||||||
} else {
|
} else {
|
||||||
memset(this->buffer, 0, sizeof(T) * count);
|
memset(this->buffer, 0, sizeof(T) * count);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user