提交 9ca7ca3d 编写于 作者: P Peter Krempa

util: alloc: Note that VIR_AUTOPTR/VIR_AUTOCLEAN must not be used with vectors

We'd free only the first element of the vector leaking the rest.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 cf3c525a
......@@ -650,6 +650,9 @@ void virAllocTestHook(void (*func)(int, void*), void *data);
* the variable declared with it by calling the function
* defined by VIR_DEFINE_AUTOPTR_FUNC when the variable
* goes out of scope.
*
* Note that this macro must NOT be used with vectors! The freeing function
* will not free any elements beyond the first.
*/
# define VIR_AUTOPTR(type) \
__attribute__((cleanup(VIR_AUTOPTR_FUNC_NAME(type)))) type *
......@@ -662,6 +665,9 @@ void virAllocTestHook(void (*func)(int, void*), void *data);
* when the variable goes out of scope.
* The cleanup function is registered by VIR_DEFINE_AUTOCLEAN_FUNC macro for
* the given type.
*
* Note that this macro must NOT be used with vectors! The cleaning function
* will not clean any elements beyond the first.
*/
# define VIR_AUTOCLEAN(type) \
__attribute__((cleanup(VIR_AUTOCLEAN_FUNC_NAME(type)))) type
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册