Skip to content

Commit

Permalink
Fix memory leak introduced in bb6814a
Browse files Browse the repository at this point in the history
  • Loading branch information
neikeq committed Apr 2, 2019
1 parent 25c1363 commit 0338e55
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions modules/mono/glue/arguments_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct ArgumentsVector {
private:
T pool[POOL_SIZE];
T *_ptr;
int size;

ArgumentsVector();
ArgumentsVector(const ArgumentsVector &);
Expand All @@ -48,11 +49,18 @@ struct ArgumentsVector {
T &get(int p_idx) { return _ptr[p_idx]; }
void set(int p_idx, const T &p_value) { _ptr[p_idx] = p_value; }

explicit ArgumentsVector(int size) {
if (size <= POOL_SIZE) {
explicit ArgumentsVector(int p_size) :
size(p_size) {
if (p_size <= POOL_SIZE) {
_ptr = pool;
} else {
_ptr = memnew_arr(T, size);
_ptr = memnew_arr(T, p_size);
}
}

~ArgumentsVector() {
if (size > POOL_SIZE) {
memdelete_arr(_ptr);
}
}
};
Expand Down

0 comments on commit 0338e55

Please sign in to comment.