From ee8df155d97830b149f4f972a253a67bfeab00bd Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Sun, 27 Sep 2015 11:24:42 +0200 Subject: [PATCH] ecore_exe: use macro to free resources Signed-off-by: Cedric BAIL --- src/lib/ecore/ecore_exe_win32.c | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/src/lib/ecore/ecore_exe_win32.c b/src/lib/ecore/ecore_exe_win32.c index 627adeb..21ddb71 100644 --- a/src/lib/ecore/ecore_exe_win32.c +++ b/src/lib/ecore/ecore_exe_win32.c @@ -57,16 +57,8 @@ _ecore_exe_threads_terminate(Ecore_Exe *obj) { exe->close_threads = 1; WaitForMultipleObjects(i, threads, TRUE, INFINITE); - if (exe->pipe_error.thread) - { - CloseHandle(exe->pipe_error.thread); - exe->pipe_error.thread = NULL; - } - if (exe->pipe_read.thread) - { - CloseHandle(exe->pipe_read.thread); - exe->pipe_read.thread = NULL; - } + IF_FN_DEL(CloseHandle, exe->pipe_error.thread); + IF_FN_DEL(CloseHandle, exe->pipe_read.thread); } } @@ -707,26 +699,16 @@ _impl_ecore_exe_eo_base_destructor(Eo *obj, Ecore_Exe_Data *exe) if (exe->pre_free_cb) exe->pre_free_cb(data, obj); - if (exe->h_close) - ecore_main_win32_handler_del(exe->h_close); - - CloseHandle(exe->process_thread); - CloseHandle(exe->process); - - if (exe->pipe_write.child_pipe) - CloseHandle(exe->pipe_write.child_pipe); - if (exe->pipe_write.child_pipe_x) - CloseHandle(exe->pipe_write.child_pipe_x); - - _ecore_exe_threads_terminate(obj); - if (exe->pipe_error.child_pipe) - CloseHandle(exe->pipe_error.child_pipe); + IF_FN_DEL(ecore_main_win32_handler_del, exe->h_close); - if (exe->pipe_read.child_pipe) - CloseHandle(exe->pipe_read.child_pipe); + IF_FN_DEL(CloseHandle, exe->process_thread); + IF_FN_DEL(CloseHandle, exe->process); + IF_FN_DEL(CloseHandle, exe->pipe_write.child_pipe); + IF_FN_DEL(CloseHandle, exe->pipe_write.child_pipe_x); + IF_FN_DEL(CloseHandle, exe->pipe_error.child_pipe); + IF_FN_DEL(CloseHandle, exe->pipe_read.child_pipe); - if (exe->cmd) - free(exe->cmd); + IF_FREE(exe->cmd); _ecore_exe_exes = eina_list_remove(_ecore_exe_exes, obj); IF_FREE(exe->tag); -- 2.7.4