From f2a771911c02ab04c344922849295c82c2cb3329 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Sep 2016 12:43:52 -0400 Subject: Fix minor memory errors in test suite --- raul/ThreadVar.hpp | 4 +++- test/array_test.cpp | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/raul/ThreadVar.hpp b/raul/ThreadVar.hpp index 7f5cf92..fa714bd 100644 --- a/raul/ThreadVar.hpp +++ b/raul/ThreadVar.hpp @@ -1,6 +1,6 @@ /* This file is part of Raul. - Copyright 2007-2012 David Robillard + Copyright 2007-2016 David Robillard Raul is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -38,6 +38,8 @@ public: } ~ThreadVar() { + T* val = (T*)pthread_getspecific(_key); + delete val; pthread_key_delete(_key); } diff --git a/test/array_test.cpp b/test/array_test.cpp index 559e834..ea9eb13 100644 --- a/test/array_test.cpp +++ b/test/array_test.cpp @@ -1,6 +1,6 @@ /* This file is part of Raul. - Copyright 2007-2013 David Robillard + Copyright 2007-2016 David Robillard Raul is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -21,12 +21,15 @@ int main(int argc, char** argv) { - Raul::Array array1(32); + Raul::Array array1(32, 2); array1[0] = 42; if (array1[0] != 42) { fprintf(stderr, "array1[0] != 42\n"); return 1; + } else if (array1[1] != 2) { + fprintf(stderr, "array1[1] != 2\n"); + return 1; } else if (array1.size() != 32) { fprintf(stderr, "array1.size() != 1\n"); return 1; @@ -44,7 +47,7 @@ main(int argc, char** argv) return 1; } - array1.alloc(8); + array1.alloc(8, 0); if (array1.size() != 8) { fprintf(stderr, "array1.size() != 8\n"); return 1; -- cgit v1.2.1