Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:GA
libvirt.14190
daefda16-introduce-macro-autostring-list.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File daefda16-introduce-macro-autostring-list.patch of Package libvirt.14190
commit daefda165b28b399478137c75b5466f865c65be5 Author: Peter Krempa <pkrempa@redhat.com> Date: Tue Feb 26 16:10:17 2019 +0100 util: string: Introduce macro for automatic string lists Similar to VIR_AUTOPTR, VIR_AUTOSTRINGLIST defines a list of strings which will be freed if the pointer is leaving scope. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Index: libvirt-5.1.0/src/libvirt_private.syms =================================================================== --- libvirt-5.1.0.orig/src/libvirt_private.syms +++ libvirt-5.1.0/src/libvirt_private.syms @@ -2958,6 +2958,7 @@ virStringHasControlChars; virStringIsEmpty; virStringIsPrintable; virStringListAdd; +virStringListAutoFree; virStringListFree; virStringListFreeCount; virStringListGetFirstWithPrefix; Index: libvirt-5.1.0/src/util/virstring.c =================================================================== --- libvirt-5.1.0.orig/src/util/virstring.c +++ libvirt-5.1.0/src/util/virstring.c @@ -318,6 +318,16 @@ void virStringListFree(char **strings) } +void virStringListAutoFree(char ***strings) +{ + if (!*strings) + return; + + virStringListFree(*strings); + *strings = NULL; +} + + /** * virStringListFreeCount: * @strings: array of strings to free Index: libvirt-5.1.0/src/util/virstring.h =================================================================== --- libvirt-5.1.0.orig/src/util/virstring.h +++ libvirt-5.1.0/src/util/virstring.h @@ -53,6 +53,7 @@ int virStringListCopy(char ***dst, const char **src); void virStringListFree(char **strings); +void virStringListAutoFree(char ***strings); void virStringListFreeCount(char **strings, size_t count); @@ -307,6 +308,15 @@ int virStringParsePort(const char *str, unsigned int *port) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; +/** + * VIR_AUTOSTRINGLIST: + * + * Declares a NULL-terminated list of strings which will be automatically freed + * when the pointer goes out of scope. + */ +# define VIR_AUTOSTRINGLIST \ + __attribute__((cleanup(virStringListAutoFree))) char ** + VIR_DEFINE_AUTOPTR_FUNC(virString, virStringListFree); #endif /* LIBVIRT_VIRSTRING_H */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor