1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

src/util: Utilize more of VIR_(APPEND|INSERT|DELETE)_ELEMENT

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2014-03-07 09:33:31 +01:00
parent 7e89de172d
commit fb9bec1055
2 changed files with 5 additions and 19 deletions

View File

@ -58,7 +58,7 @@ typedef virJSONParser *virJSONParserPtr;
struct _virJSONParser {
virJSONValuePtr head;
virJSONParserStatePtr state;
unsigned int nstate;
size_t nstate;
};
@ -889,10 +889,7 @@ static int virJSONParserHandleEndMap(void *ctx)
return 0;
}
if (VIR_REALLOC_N(parser->state,
parser->nstate - 1) < 0)
return 0;
parser->nstate--;
VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate);
return 1;
}
@ -939,10 +936,7 @@ static int virJSONParserHandleEndArray(void *ctx)
return 0;
}
if (VIR_REALLOC_N(parser->state,
parser->nstate - 1) < 0)
return 0;
parser->nstate--;
VIR_DELETE_ELEMENT(parser->state, parser->nstate - 1, parser->nstate);
return 1;
}

View File

@ -689,11 +689,7 @@ int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
goto cleanup;
}
if (i < (res->nOwners - 1))
memmove(res->owners + i,
res->owners + i + 1,
(res->nOwners - i - 1) * sizeof(res->owners[0]));
VIR_SHRINK_N(res->owners, res->nOwners, 1);
VIR_DELETE_ELEMENT(res->owners, i, res->nOwners);
if ((res->nOwners == 0) &&
virHashRemoveEntry(lockspace->resources, resname) < 0)
@ -735,11 +731,7 @@ virLockSpaceRemoveResourcesForOwner(const void *payload,
data->count++;
if (i < (res->nOwners - 1))
memmove(res->owners + i,
res->owners + i + 1,
(res->nOwners - i - 1) * sizeof(res->owners[0]));
VIR_SHRINK_N(res->owners, res->nOwners, 1);
VIR_DELETE_ELEMENT(res->owners, i, res->nOwners);
if (res->nOwners) {
VIR_DEBUG("Other shared owners remain");