[libvirt] [PATCH 1/4] util: alloc: Remove pointless clearing of variable in AUTOPTR_FUNCs

Peter Krempa pkrempa at redhat.com
Fri Feb 22 16:04:37 UTC 2019


VIR_DEFINE_AUTOPTR_FUNC defines a function which is supposed to free the
resources for the given VIR_AUTOPTR variable. Given that the cleanup
function is executed when the stack frame is being destroyed it does not
make much sense to set the pointer to NULL.

Making the inline function contain less code also decreases the
possibility that for a given type the inlining will be declined by the
compiler due to increasing code size.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/util/viralloc.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/util/viralloc.h b/src/util/viralloc.h
index 15451d4673..50a07d4fa3 100644
--- a/src/util/viralloc.h
+++ b/src/util/viralloc.h
@@ -612,7 +612,6 @@ void virAllocTestHook(void (*func)(int, void*), void *data);
     { \
         if (*_ptr) \
             (func)(*_ptr); \
-        *_ptr = NULL; \
     }

 # define VIR_AUTOCLEAN_FUNC_NAME(type) type##AutoClean
-- 
2.20.1




More information about the libvir-list mailing list