set CHANGE rename set number to count
diff --git a/src/set.c b/src/set.c
index dd37767..6cfc0af 100644
--- a/src/set.c
+++ b/src/set.c
@@ -41,7 +41,7 @@
LY_CHECK_ARG_RET(NULL, set, -1);
- for (i = 0; i < set->number; i++) {
+ for (i = 0; i < set->count; i++) {
if (set->objs[i] == object) {
/* object found */
return i;
@@ -61,7 +61,7 @@
new = malloc(sizeof *new);
LY_CHECK_ERR_RET(!new, LOGMEM(NULL), NULL);
- new->number = set->number;
+ new->count = set->count;
new->size = set->size;
new->objs = malloc(new->size * sizeof *(new->objs));
LY_CHECK_ERR_RET(!new->objs, LOGMEM(NULL); free(new), NULL);
@@ -80,7 +80,7 @@
if (!(options & LY_SET_OPT_USEASLIST)) {
/* search for duplication */
- for (i = 0; i < set->number; i++) {
+ for (i = 0; i < set->count; i++) {
if (set->objs[i] == object) {
/* already in set */
return i;
@@ -88,16 +88,16 @@
}
}
- if (set->size == set->number) {
+ if (set->size == set->count) {
new = realloc(set->objs, (set->size + 8) * sizeof *(set->objs));
LY_CHECK_ERR_RET(!new, LOGMEM(NULL), -1);
set->size += 8;
set->objs = new;
}
- set->objs[set->number++] = object;
+ set->objs[set->count++] = object;
- return set->number - 1;
+ return set->count - 1;
}
API int
@@ -112,7 +112,7 @@
if (!(options & LY_SET_OPT_USEASLIST)) {
/* remove duplicates */
i = 0;
- while (i < src->number) {
+ while (i < src->count) {
if (ly_set_contains(trg, src->objs[i]) > -1) {
ly_set_rm_index(src, i);
} else {
@@ -122,17 +122,17 @@
}
/* allocate more memory if needed */
- if (trg->size < trg->number + src->number) {
- new = realloc(trg->objs, (trg->number + src->number) * sizeof *(trg->objs));
+ if (trg->size < trg->count + src->count) {
+ new = realloc(trg->objs, (trg->count + src->count) * sizeof *(trg->objs));
LY_CHECK_ERR_RET(!new, LOGMEM(NULL), -1);
- trg->size = trg->number + src->number;
+ trg->size = trg->count + src->count;
trg->objs = new;
}
/* copy contents from src into trg */
- memcpy(trg->objs + trg->number, src->objs, src->number * sizeof *(src->objs));
- ret = src->number;
- trg->number += ret;
+ memcpy(trg->objs + trg->count, src->objs, src->count * sizeof *(src->objs));
+ ret = src->count;
+ trg->count += ret;
/* cleanup */
ly_set_free(src);
@@ -143,17 +143,17 @@
ly_set_rm_index(struct ly_set *set, unsigned int index)
{
LY_CHECK_ARG_RET(NULL, set, LY_EINVAL);
- LY_CHECK_ERR_RET(((index + 1) > set->number), LOGARG(NULL, set), LY_EINVAL);
+ LY_CHECK_ERR_RET(((index + 1) > set->count), LOGARG(NULL, set), LY_EINVAL);
- if (index == set->number - 1) {
+ if (index == set->count - 1) {
/* removing last item in set */
set->objs[index] = NULL;
} else {
/* removing item somewhere in a middle, so put there the last item */
- set->objs[index] = set->objs[set->number - 1];
- set->objs[set->number - 1] = NULL;
+ set->objs[index] = set->objs[set->count - 1];
+ set->objs[set->count - 1] = NULL;
}
- set->number--;
+ set->count--;
return LY_SUCCESS;
}
@@ -166,12 +166,12 @@
LY_CHECK_ARG_RET(NULL, set, object, LY_EINVAL);
/* get index */
- for (i = 0; i < set->number; i++) {
+ for (i = 0; i < set->count; i++) {
if (set->objs[i] == object) {
break;
}
}
- LY_CHECK_ERR_RET((i == set->number), LOGARG(NULL, set), LY_EINVAL); /* object is not in set */
+ LY_CHECK_ERR_RET((i == set->count), LOGARG(NULL, set), LY_EINVAL); /* object is not in set */
return ly_set_rm_index(set, i);
}
@@ -181,6 +181,6 @@
{
LY_CHECK_ARG_RET(NULL, set, LY_EINVAL);
- set->number = 0;
+ set->count = 0;
return LY_SUCCESS;
}