[vlc-devel] [PATCH] threads: make vlc_cleanup_push call the cleanup function in C++ on Win32/OS2

Steve Lhomme robux4 at ycbcr.xyz
Mon Feb 10 14:55:44 CET 2020


Should fix #23591
---
 include/vlc_threads.h | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 0e27ea803fa..b2ef5222d3b 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -1071,26 +1071,18 @@ struct vlc_cleanup_t
     void          *data;
 };
 
-# ifndef __cplusplus
 /* This macros opens a code block on purpose: It reduces the chance of
  * not pairing the push and pop. It also matches the POSIX Thread internals.
  * That way, Win32 developers will not accidentally break other platforms.
  */
 # define vlc_cleanup_push( routine, arg ) \
     do { \
-        vlc_control_cancel(&(vlc_cleanup_t){ NULL, routine, arg })
+        vlc_cleanup_t _cleanup = (vlc_cleanup_t){ NULL, routine, arg }; \
+        vlc_control_cancel(&_cleanup)
 
 #  define vlc_cleanup_pop( ) \
         vlc_control_cancel (NULL); \
     } while (0)
-# else
-/* Those macros do not work in C++. However common C/C++ helpers may call them
- * anyway - this is fine if the code is never cancelled in C++ case.
- * So define the macros to do nothing.
- */
-#  define vlc_cleanup_push(routine, arg) do { (routine, arg)
-#  define vlc_cleanup_pop() } while (0)
-# endif
 
 #endif /* !LIBVLC_USE_PTHREAD_CLEANUP */
 
-- 
2.17.1



More information about the vlc-devel mailing list