Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/util/virjson.c | 12 +++---------
src/util/virlockspace.c | 12 ++----------
2 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 7044e11..02b5f3f 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -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;
}
diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index cab7775..90a39bb 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -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");
--
1.9.0