*countptr = 0;
errno = save_errno;
}
+
+
+/**
+ * virDisposeString:
+ * @ptrptr: pointer to pointer for a string which should be sanitized and cleared
+ *
+ * See virDispose.
+ */
+void
+virDisposeString(char **strptr)
+{
+ if (!*strptr)
+ return;
+
+ virDispose(strptr, strlen(*strptr), sizeof(char), NULL);
+}
void virDispose(void *ptrptr, size_t count, size_t element_size, size_t *countptr)
ATTRIBUTE_NONNULL(1);
+void virDisposeString(char **strptr)
+ ATTRIBUTE_NONNULL(1);
/**
* VIR_ALLOC:
*
* This macro is not safe to be used on arguments with side effects.
*/
-# define VIR_DISPOSE_STRING(ptr) virDispose(1 ? (void *) &(ptr) : (ptr), \
- (ptr) ? strlen((ptr)) : 0, 1, NULL)
+# define VIR_DISPOSE_STRING(ptr) virDisposeString(&(ptr))
+/**
+ * VIR_AUTODISPOSE_STR:
+ *
+ * Macro to automatically free and clear the memory allocated to
+ * the string variable declared with it by calling virDisposeString
+ * when the variable goes out of scope.
+ */
+# define VIR_AUTODISPOSE_STR \
+ __attribute__((cleanup(virDisposeString))) char *
/**
* VIR_DISPOSE: