]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virthread: Register auto cleanup function for virMutex
authorPeter Krempa <pkrempa@redhat.com>
Wed, 4 Jun 2025 19:56:25 +0000 (21:56 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 12 Jun 2025 08:17:03 +0000 (10:17 +0200)
This makes it very convenient to declare a mutex on stack along with the
VIR_MUTEX_INITIALIZE macro without the need to have complex cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/virthread.h

index 23abe0b6c92a39cbd4118e85cedb35ba3687da62..a7ec6bf32c5b5de8de608dc824632d219987fc1e 100644 (file)
@@ -121,6 +121,7 @@ int virOnce(virOnceControl *once, virOnceFunc init)
 int virMutexInit(virMutex *m) G_GNUC_WARN_UNUSED_RESULT;
 int virMutexInitRecursive(virMutex *m) G_GNUC_WARN_UNUSED_RESULT;
 void virMutexDestroy(virMutex *m);
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virMutex, virMutexDestroy);
 
 void virMutexLock(virMutex *m);
 void virMutexUnlock(virMutex *m);