if (virReallocN(ptrptr, size, *countptr -= toremove) < 0)
abort();
} else {
- virFree(ptrptr);
+ g_free(*((void **)ptrptr));
+ *((void **)ptrptr) = NULL;
*countptr = 0;
}
}
}
-/**
- * virFree:
- * @ptrptr: pointer to pointer for address of memory to be freed
- *
- * Release the chunk of memory in the pointer pointed to by
- * the 'ptrptr' variable. After release, 'ptrptr' will be
- * updated to point to NULL.
- */
-void virFree(void *ptrptr)
-{
- int save_errno = errno;
-
- g_free(*(void**)ptrptr);
- *(void**)ptrptr = NULL;
- errno = save_errno;
-}
-
-
/**
* virDispose:
* @ptrptr: pointer to pointer for address of memory to be sanitized and freed
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
int virAllocVar(void *ptrptr, size_t struct_size, size_t element_size, size_t count)
G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
-void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1);
void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countptr)
ATTRIBUTE_NONNULL(1);
*
* This macro is safe to use on arguments with side effects.
*/
-/* The ternary ensures that ptr is a non-const pointer and not an
- * integer type, all while evaluating ptr only once. This gives us
- * extra compiler safety when compiling under gcc.
- */
-#define VIR_FREE(ptr) virFree(1 ? (void *) &(ptr) : (ptr))
+#define VIR_FREE(ptr) g_clear_pointer(&(ptr), g_free)
/**