Skip to content

Commit

Permalink
#164 alex-c-collection 1.4.0 -> 1.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis committed Dec 22, 2024
1 parent 926f9a9 commit 426fe35
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/col/.source
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[email protected]:alex-courtis/alex-c-collections.git v1.4.0
[email protected]:alex-courtis/alex-c-collections.git v1.4.1
2 changes: 1 addition & 1 deletion lib/col/inc/ptable.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const struct PTableIter *ptable_next(const struct PTableIter* const iter);
* Mutate
*/

// set key/val, return old val if overwritten
// set key/val, return old val if overwritten, NULL val to remove
const void *ptable_put(const struct PTable* const tab, const void* const key, const void* const val);

// remove key, return old val if present
Expand Down
24 changes: 10 additions & 14 deletions lib/col/src/itable.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,15 @@ const struct ITableIter *itable_iter(const struct ITable* const tab) {
for (k = tab->keys, v = tab->vals;
v < tab->vals + tab->size && k < tab->keys + tab->size;
k++, v++) {
if (*v) {
struct ITableIterP *iterp = calloc(1, sizeof(struct ITableIterP));
struct ITableIterP *iterp = calloc(1, sizeof(struct ITableIterP));

iterp->tab = tab;
iterp->key = *k;
iterp->val = *v;
iterp->k = k;
iterp->v = v;
iterp->tab = tab;
iterp->key = *k;
iterp->val = *v;
iterp->k = k;
iterp->v = v;

return (struct ITableIter*)iterp;
}
return (struct ITableIter*)iterp;
}

return NULL;
Expand All @@ -159,11 +157,9 @@ const struct ITableIter *itable_next(const struct ITableIter* const iter) {
// loop over keys and vals
while (++iterp->v < iterp->tab->vals + iterp->tab->size &&
++iterp->k < iterp->tab->keys + iterp->tab->size) {
if (*iterp->v) {
iterp->key = *(iterp->k);
iterp->val = *(iterp->v);
return iter;
}
iterp->key = *(iterp->k);
iterp->val = *(iterp->v);
return iter;
}

itable_iter_free(iter);
Expand Down
24 changes: 10 additions & 14 deletions lib/col/src/stable.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,15 @@ const struct STableIter *stable_iter(const struct STable* const tab) {
for (k = tab->keys, v = tab->vals;
v < tab->vals + tab->size && k < tab->keys + tab->size;
k++, v++) {
if (*v) {
struct STableIterP *iterp = calloc(1, sizeof(struct STableIterP));
struct STableIterP *iterp = calloc(1, sizeof(struct STableIterP));

iterp->tab = tab;
iterp->key = *k;
iterp->val = *v;
iterp->k = k;
iterp->v = v;
iterp->tab = tab;
iterp->key = *k;
iterp->val = *v;
iterp->k = k;
iterp->v = v;

return (struct STableIter*)iterp;
}
return (struct STableIter*)iterp;
}

return NULL;
Expand All @@ -171,11 +169,9 @@ const struct STableIter *stable_next(const struct STableIter* const iter) {
// loop over keys and vals
while (++iterp->v < iterp->tab->vals + iterp->tab->size &&
++iterp->k < iterp->tab->keys + iterp->tab->size) {
if (*iterp->v) {
iterp->key = *(iterp->k);
iterp->val = *(iterp->v);
return iter;
}
iterp->key = *(iterp->k);
iterp->val = *(iterp->v);
return iter;
}

stable_iter_free(iter);
Expand Down

0 comments on commit 426fe35

Please sign in to comment.