OSDN Git Service

android/tester: Fix memory leak
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Fri, 20 Dec 2013 12:35:35 +0000 (14:35 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 20 Dec 2013 12:42:05 +0000 (14:42 +0200)
commitb11f10f8142a745cada3bd171d56959f1edb439d
tree2f95e1f1a9d4198ee444c6e5a234e2a11ea170c3
parentb3c0a8a339fe2faf73d49e0ef9ea7f9a4123cc16
android/tester: Fix memory leak

Call del_hook() after add_hook(). This fixes valgrind warnings:

...
==15303==
==15303== HEAP SUMMARY:
==15303==     in use at exit: 3,060 bytes in 27 blocks
==15303==   total heap usage: 6,410 allocs, 6,383 frees, 332,477 bytes
allocated
==15303==
==15303== 24 bytes in 1 blocks are definitely lost in loss record 9 of
27
==15303==    at 0x4C2A2DB: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15303==    by 0x406E20: btdev_add_hook (btdev.c:2166)
==15303==    by 0x40BFC2: test_discovery_start_done
(android-tester.c:1401)
==15303==    by 0x409C65: run_callback (tester.c:385)
==15303==    by 0x4E7C3B5: g_main_context_dispatch (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x4E7C707: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x4E7CB09: g_main_loop_run (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x40A85C: tester_run (tester.c:784)
==15303==    by 0x40368B: main (android-tester.c:1654)
==15303==
==15303== 24 bytes in 1 blocks are definitely lost in loss record 10 of
27
==15303==    at 0x4C2A2DB: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==15303==    by 0x406E20: btdev_add_hook (btdev.c:2166)
==15303==    by 0x40BF12: test_discovery_stop_success
(android-tester.c:1386)
==15303==    by 0x409C65: run_callback (tester.c:385)
==15303==    by 0x4E7C3B5: g_main_context_dispatch (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x4E7C707: ??? (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x4E7CB09: g_main_loop_run (in
/lib/x86_64-linux-gnu/libglib-2.0.so.0.3800.1)
==15303==    by 0x40A85C: tester_run (tester.c:784)
==15303==    by 0x40368B: main (android-tester.c:1654)
==15303==
...
android/android-tester.c