util: convert virSystemdActivation to use VIR_DEFINE_AUTOPTR_FUNC

Using the standard macro will facilitate the conversion to glib's
auto cleanup macros.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2019-10-01 10:50:34 +01:00
parent bb9a1a14e2
commit 74d9326795
3 changed files with 9 additions and 8 deletions

View File

@ -917,7 +917,7 @@ virSystemdActivationNew(virSystemdActivationMap *map,
return act; return act;
error: error:
virSystemdActivationFree(&act); virSystemdActivationFree(act);
return NULL; return NULL;
} }
@ -1046,12 +1046,12 @@ virSystemdActivationClaimFDs(virSystemdActivationPtr act,
* associated with the activation object * associated with the activation object
*/ */
void void
virSystemdActivationFree(virSystemdActivationPtr *act) virSystemdActivationFree(virSystemdActivationPtr act)
{ {
if (!*act) if (!act)
return; return;
virHashFree((*act)->fds); virHashFree(act->fds);
VIR_FREE(*act); VIR_FREE(act);
} }

View File

@ -22,6 +22,7 @@
#pragma once #pragma once
#include "internal.h" #include "internal.h"
#include "virautoclean.h"
typedef struct _virSystemdActivation virSystemdActivation; typedef struct _virSystemdActivation virSystemdActivation;
typedef virSystemdActivation *virSystemdActivationPtr; typedef virSystemdActivation *virSystemdActivationPtr;
@ -81,6 +82,6 @@ void virSystemdActivationClaimFDs(virSystemdActivationPtr act,
int **fds, int **fds,
size_t *nfds); size_t *nfds);
void virSystemdActivationFree(virSystemdActivationPtr *act); void virSystemdActivationFree(virSystemdActivationPtr act);
#define virSystemdActivationAutoPtrFree virSystemdActivationFree VIR_DEFINE_AUTOPTR_FUNC(virSystemdActivation, virSystemdActivationFree);

View File

@ -650,7 +650,7 @@ testActivationEmpty(const void *opaque ATTRIBUTE_UNUSED)
if (act != NULL) { if (act != NULL) {
fprintf(stderr, "Unexpectedly got activation object"); fprintf(stderr, "Unexpectedly got activation object");
virSystemdActivationFree(&act); virSystemdActivationFree(act);
return -1; return -1;
} }