set CHANGE rename set number to count
diff --git a/src/context.c b/src/context.c
index 2fe6148..74fc2ea 100644
--- a/src/context.c
+++ b/src/context.c
@@ -102,7 +102,7 @@
API LY_ERR
ly_ctx_unset_searchdirs(struct ly_ctx *ctx, int index)
{
- if (!ctx->search_paths.number) {
+ if (!ctx->search_paths.count) {
return LY_SUCCESS;
}
@@ -111,8 +111,8 @@
return ly_set_rm_index(&ctx->search_paths, index);
} else {
/* remove them all */
- for (; ctx->search_paths.number; ctx->search_paths.number--) {
- free(ctx->search_paths.objs[ctx->search_paths.number - 1]);
+ for (; ctx->search_paths.count; ctx->search_paths.count--) {
+ free(ctx->search_paths.objs[ctx->search_paths.count - 1]);
}
free(ctx->search_paths.objs);
memset(&ctx->search_paths, 0, sizeof ctx->search_paths);
@@ -271,10 +271,10 @@
LY_CHECK_ARG_RET(ctx, ctx,);
/* models list */
- for (; ctx->list.number; ctx->list.number--) {
+ for (; ctx->list.count; ctx->list.count--) {
/* remove the module */
#if 0 /* TODO when parser implemented */
- lys_free(ctx->list[ctx->list.number - 1], private_destructor, 1, 0);
+ lys_free(ctx->list[ctx->list.count - 1], private_destructor, 1, 0);
#endif
}
free(ctx->list.objs);
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;
}
diff --git a/src/set.h b/src/set.h
index cb5bfa0..f1df154 100644
--- a/src/set.h
+++ b/src/set.h
@@ -42,7 +42,7 @@
struct ly_set
{
unsigned int size; /**< allocated size of the set array */
- unsigned int number; /**< number of elements in (used size of) the set array */
+ unsigned int count; /**< number of elements in (used size of) the set array */
union
{
struct lys_node **schemas; /**< array of pointers to a ::lys_node objects */
@@ -62,7 +62,7 @@
*
* @return Created ::ly_set structure or NULL in case of error.
*/
-struct ly_set *ly_set_new (void);
+struct ly_set *ly_set_new(void);
/**
* @brief Duplicate the existing set.
@@ -70,7 +70,7 @@
* @param[in] set Original set to duplicate
* @return Duplication of the original set.
*/
-struct ly_set *ly_set_dup (const struct ly_set *set);
+struct ly_set *ly_set_dup(const struct ly_set *set);
/**
* @brief Add a ::lyd_node or ::lys_node object into the set
@@ -85,7 +85,7 @@
* - #LY_SET_OPT_USEASLIST - do not check for duplicities
* @return -1 on failure, index of the \p node in the set on success
*/
-int ly_set_add (struct ly_set *set, void *object, int options);
+int ly_set_add(struct ly_set *set, void *object, int options);
/**
* @brief Add all objects from \p src to \p trg.
@@ -99,7 +99,7 @@
* - #LY_SET_OPT_USEASLIST - do not check for duplicities
* @return -1 on failure, number of objects added into \p trg on success.
*/
-int ly_set_merge (struct ly_set *trg, struct ly_set *src, int options);
+int ly_set_merge(struct ly_set *trg, struct ly_set *src, int options);
/**
* @brief Get know if the set contains the specified object.
@@ -107,7 +107,7 @@
* @param[in] object Object to be found in the set.
* @return Index of the object in the set or -1 if the object is not present in the set.
*/
-int ly_set_contains (const struct ly_set *set, void *object);
+int ly_set_contains(const struct ly_set *set, void *object);
/**
* @brief Remove all objects from the set, but keep the set container for further use.
@@ -115,7 +115,7 @@
* @param[in] set Set to clean.
* @return LY_ERR return value.
*/
-LY_ERR ly_set_clean (struct ly_set *set);
+LY_ERR ly_set_clean(struct ly_set *set);
/**
* @brief Remove an object from the set.
@@ -127,7 +127,7 @@
* @param[in] obejct The object to be removed from the \p set.
* @return LY_ERR return value.
*/
-LY_ERR ly_set_rm (struct ly_set *set, void *object);
+LY_ERR ly_set_rm(struct ly_set *set, void *object);
/**
* @brief Remove an object on the specific set index.
@@ -139,14 +139,14 @@
* @param[in] index Index of the object to remove in the \p set.
* @return LY_ERR return value.
*/
-LY_ERR ly_set_rm_index (struct ly_set *set, unsigned int index);
+LY_ERR ly_set_rm_index(struct ly_set *set, unsigned int index);
/**
* @brief Free the ::ly_set data. Frees only the set structure content, not the referred data.
*
* @param[in] set The set to be freed.
*/
-void ly_set_free (struct ly_set *set);
+void ly_set_free(struct ly_set *set);
/** @} lyset */