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:
parent
7e89de172d
commit
fb9bec1055
@ -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;
|
||||
}
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user