summaryrefslogtreecommitdiff
path: root/src/libdatastruct
diff options
context:
space:
mode:
Diffstat (limited to 'src/libdatastruct')
-rw-r--r--src/libdatastruct/avlnode-internal.h5
-rw-r--r--src/libdatastruct/avlnode_delete.c11
-rw-r--r--src/libdatastruct/avlnode_doublerotate.c7
-rw-r--r--src/libdatastruct/avlnode_extreme.c5
-rw-r--r--src/libdatastruct/avlnode_extremenode.c5
-rw-r--r--src/libdatastruct/avlnode_height.c3
-rw-r--r--src/libdatastruct/avlnode_insertnode.c7
-rw-r--r--src/libdatastruct/avlnode_iter.c11
-rw-r--r--src/libdatastruct/avlnode_iter_withcancel.c5
-rw-r--r--src/libdatastruct/avlnode_rotate.c5
-rw-r--r--src/libdatastruct/avlnode_search.c6
-rw-r--r--src/libdatastruct/avlnode_searchnode.c5
-rw-r--r--src/libdatastruct/avltree_delete.c5
-rw-r--r--src/libdatastruct/avltree_init.c5
-rw-r--r--src/libdatastruct/avltree_insert.c5
-rw-r--r--src/libdatastruct/avltree_newnode.c7
-rw-r--r--src/libdatastruct/avltreen_delete.c5
-rw-r--r--src/libdatastruct/avltreen_init.c3
-rw-r--r--src/libdatastruct/avltreen_insert.c5
-rw-r--r--src/libdatastruct/avltreen_newnode.c7
-rw-r--r--src/libdatastruct/genset.c11
-rw-r--r--src/libdatastruct/genset_iter_nocancel.c5
-rw-r--r--src/libdatastruct/genset_iter_withcancel.c3
-rw-r--r--src/libdatastruct/gensetdyn_delete.c5
-rw-r--r--src/libdatastruct/gensetdyn_free.c3
-rw-r--r--src/libdatastruct/gensetdyn_init.c3
-rw-r--r--src/libdatastruct/gensetdyn_iter.c13
-rw-r--r--src/libdatastruct/gensetdyn_iter_withcancel.c3
-rw-r--r--src/libdatastruct/gensetdyn_new.c14
-rw-r--r--src/libdatastruct/gensetdyn_ready.c11
30 files changed, 111 insertions, 77 deletions
diff --git a/src/libdatastruct/avlnode-internal.h b/src/libdatastruct/avlnode-internal.h
index 2151cf3..1053fdc 100644
--- a/src/libdatastruct/avlnode-internal.h
+++ b/src/libdatastruct/avlnode-internal.h
@@ -3,13 +3,14 @@
#ifndef AVLNODE_INTERNAL_H
#define AVLNODE_INTERNAL_H
+#include <stdint.h>
#include <skalibs/avlnode.h>
#define avlnode_ufroms(c) ((c) > 0)
#define avlnode_sfromu(h) ((h) ? 1 : -1)
-extern unsigned int avlnode_rotate (avlnode *, unsigned int, unsigned int, int) ;
-extern unsigned int avlnode_doublerotate (avlnode *, unsigned int, unsigned int, int) ;
+extern uint32_t avlnode_rotate (avlnode *, uint32_t, uint32_t, int) ;
+extern uint32_t avlnode_doublerotate (avlnode *, uint32_t, uint32_t, int) ;
#define avlnode_rotate_maydouble(s, max, r, h, isdouble) ((isdouble) ? avlnode_doublerotate(s, max, r, h) : avlnode_rotate(s, max, r, h))
#endif
diff --git a/src/libdatastruct/avlnode_delete.c b/src/libdatastruct/avlnode_delete.c
index fffb212..fa9e0b6 100644
--- a/src/libdatastruct/avlnode_delete.c
+++ b/src/libdatastruct/avlnode_delete.c
@@ -1,20 +1,21 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/functypes.h>
#include <skalibs/avlnode.h>
#include "avlnode-internal.h"
-unsigned int avlnode_delete (avlnode *s, unsigned int max, unsigned int *root, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+uint32_t avlnode_delete (avlnode *s, uint32_t max, uint32_t *root, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
- unsigned int stack[AVLNODE_MAXDEPTH] ;
+ uint32_t stack[AVLNODE_MAXDEPTH] ;
int spin[AVLNODE_MAXDEPTH] ;
unsigned int sp = 0 ;
- unsigned int r = *root ;
- unsigned int itodel ;
+ uint32_t r = *root ;
+ uint32_t itodel ;
for (; r < max ; sp++)
{
- register int c = (*f)(k, (*dtok)(s[r].data, p), p) ;
+ int c = (*f)(k, (*dtok)(s[r].data, p), p) ;
if (!c) break ;
spin[sp] = avlnode_ufroms(c) ;
stack[sp] = r ;
diff --git a/src/libdatastruct/avlnode_doublerotate.c b/src/libdatastruct/avlnode_doublerotate.c
index da1f31b..cadbf12 100644
--- a/src/libdatastruct/avlnode_doublerotate.c
+++ b/src/libdatastruct/avlnode_doublerotate.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avlnode.h>
#include "avlnode-internal.h"
-unsigned int avlnode_doublerotate (avlnode_ref s, unsigned int max, unsigned int i, int h)
+uint32_t avlnode_doublerotate (avlnode_ref s, uint32_t max, uint32_t i, int h)
{
- register unsigned int j = s[i].child[!h] ;
- register unsigned int k = s[j].child[h] ;
+ uint32_t j = s[i].child[!h] ;
+ uint32_t k = s[j].child[h] ;
s[i].child[!h] = s[k].child[h] ;
s[j].child[h] = s[k].child[!h] ;
s[k].child[!h] = j ;
diff --git a/src/libdatastruct/avlnode_extreme.c b/src/libdatastruct/avlnode_extreme.c
index 42d991d..cfdf98c 100644
--- a/src/libdatastruct/avlnode_extreme.c
+++ b/src/libdatastruct/avlnode_extreme.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/avlnode.h>
-int avlnode_extreme (avlnode const *s, unsigned int max, unsigned int r, int h, unsigned int *k)
+int avlnode_extreme (avlnode const *s, uint32_t max, uint32_t r, int h, uint32_t *k)
{
- register unsigned int i = avlnode_extremenode(s, max, r, h) ;
+ uint32_t i = avlnode_extremenode(s, max, r, h) ;
if (i >= max) return (errno = ESRCH, 0) ;
*k = s[i].data ;
return 1 ;
diff --git a/src/libdatastruct/avlnode_extremenode.c b/src/libdatastruct/avlnode_extremenode.c
index 57a8e59..2efb491 100644
--- a/src/libdatastruct/avlnode_extremenode.c
+++ b/src/libdatastruct/avlnode_extremenode.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avlnode.h>
-unsigned int avlnode_extremenode (avlnode const *s, unsigned int max, unsigned int r, int h)
+uint32_t avlnode_extremenode (avlnode const *s, uint32_t max, uint32_t r, int h)
{
- register unsigned int oldr = r ;
+ uint32_t oldr = r ;
for (; r < max ; oldr = r, r = s[r].child[h]) ;
return oldr ;
}
diff --git a/src/libdatastruct/avlnode_height.c b/src/libdatastruct/avlnode_height.c
index e78448e..50c5670 100644
--- a/src/libdatastruct/avlnode_height.c
+++ b/src/libdatastruct/avlnode_height.c
@@ -1,8 +1,9 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avlnode.h>
-unsigned int avlnode_height (avlnode const *s, unsigned int max, unsigned int r)
+unsigned int avlnode_height (avlnode const *s, uint32_t max, uint32_t r)
{
if (r >= max) return 0 ;
else if (s[r].balance) return 1 + avlnode_height(s, max, s[r].child[s[r].balance > 0]) ;
diff --git a/src/libdatastruct/avlnode_insertnode.c b/src/libdatastruct/avlnode_insertnode.c
index ac44877..e7e68b8 100644
--- a/src/libdatastruct/avlnode_insertnode.c
+++ b/src/libdatastruct/avlnode_insertnode.c
@@ -1,17 +1,18 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/functypes.h>
#include <skalibs/avlnode.h>
#include "avlnode-internal.h"
-unsigned int avlnode_insertnode (avlnode *s, unsigned int max, unsigned int r, unsigned int i, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+uint32_t avlnode_insertnode (avlnode *s, uint32_t max, uint32_t r, uint32_t i, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
- unsigned int stack[AVLNODE_MAXDEPTH] ;
+ uint32_t stack[AVLNODE_MAXDEPTH] ;
int spin[AVLNODE_MAXDEPTH] ;
unsigned int sp = 0 ;
{
- register void const *k = (*dtok)(s[i].data, p) ;
+ void const *k = (*dtok)(s[i].data, p) ;
for (; r < max ; sp++)
{
spin[sp] = avlnode_ufroms((*f)(k, (*dtok)(s[r].data, p), p)) ;
diff --git a/src/libdatastruct/avlnode_iter.c b/src/libdatastruct/avlnode_iter.c
index e1b17de..47813f2 100644
--- a/src/libdatastruct/avlnode_iter.c
+++ b/src/libdatastruct/avlnode_iter.c
@@ -1,21 +1,22 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avlnode.h>
struct avlnode_iter_s
{
avlnode const *s ;
- unsigned int max ;
- unsigned int cut ;
+ uint32_t max ;
+ uint32_t cut ;
avliterfunc_t_ref f ;
void *p ;
} ;
-static unsigned int avlnode_iter_rec (struct avlnode_iter_s const *blah, unsigned int r, unsigned int h)
+static uint32_t avlnode_iter_rec (struct avlnode_iter_s const *blah, uint32_t r, unsigned int h)
{
if (r >= blah->max) return blah->max ;
{
- unsigned int res = avlnode_iter_rec(blah, blah->s[r].child[0], h+1) ;
+ uint32_t res = avlnode_iter_rec(blah, blah->s[r].child[0], h+1) ;
if (res != blah->max) return res ;
}
if (r == blah->cut) return blah->max ;
@@ -23,7 +24,7 @@ static unsigned int avlnode_iter_rec (struct avlnode_iter_s const *blah, unsigne
return avlnode_iter_rec(blah, blah->s[r].child[1], h+1) ;
}
-unsigned int avlnode_iter_nocancel (avlnode *s, unsigned int max, unsigned int cut, unsigned int r, avliterfunc_t_ref f, void *p)
+uint32_t avlnode_iter_nocancel (avlnode *s, uint32_t max, uint32_t cut, uint32_t r, avliterfunc_t_ref f, void *p)
{
struct avlnode_iter_s blah = { .s = s, .max = max, .cut = cut, .f = f, .p = p } ;
return avlnode_iter_rec(&blah, r, 0) ;
diff --git a/src/libdatastruct/avlnode_iter_withcancel.c b/src/libdatastruct/avlnode_iter_withcancel.c
index 44ba12e..d92e767 100644
--- a/src/libdatastruct/avlnode_iter_withcancel.c
+++ b/src/libdatastruct/avlnode_iter_withcancel.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/avlnode.h>
-int avlnode_iter_withcancel (avlnode *tree, unsigned int max, unsigned int root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff)
+int avlnode_iter_withcancel (avlnode *tree, uint32_t max, uint32_t root, avliterfunc_t_ref f, avliterfunc_t_ref cancelf, void *stuff)
{
- unsigned int cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ;
+ uint32_t cut = avlnode_iter_nocancel(tree, max, max, root, f, stuff) ;
if (cut != max)
{
int e = errno ;
diff --git a/src/libdatastruct/avlnode_rotate.c b/src/libdatastruct/avlnode_rotate.c
index f2f75d7..6f45477 100644
--- a/src/libdatastruct/avlnode_rotate.c
+++ b/src/libdatastruct/avlnode_rotate.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avlnode.h>
#include "avlnode-internal.h"
-unsigned int avlnode_rotate (avlnode *s, unsigned int max, unsigned int i, int h)
+uint32_t avlnode_rotate (avlnode *s, uint32_t max, uint32_t i, int h)
{
- register unsigned int j = s[i].child[!h] ;
+ uint32_t j = s[i].child[!h] ;
s[i].child[!h] = s[j].child[h] ;
s[j].child[h] = i ;
if (s[j].balance * avlnode_sfromu(h) < 0) s[i].balance = s[j].balance = 0 ;
diff --git a/src/libdatastruct/avlnode_search.c b/src/libdatastruct/avlnode_search.c
index e12b0a4..85073ca 100644
--- a/src/libdatastruct/avlnode_search.c
+++ b/src/libdatastruct/avlnode_search.c
@@ -1,11 +1,13 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
+#include <skalibs/functypes.h>
#include <skalibs/avlnode.h>
-int avlnode_search (avlnode const *s, unsigned int max, unsigned int r, void const *k, unsigned int *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+int avlnode_search (avlnode const *s, uint32_t max, uint32_t r, void const *k, uint32_t *data, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
- register unsigned int i = avlnode_searchnode(s, max, r, k, dtok, f, p) ;
+ uint32_t i = avlnode_searchnode(s, max, r, k, dtok, f, p) ;
if (i >= max) return (errno = ESRCH, 0) ;
*data = s[i].data ;
return 1 ;
diff --git a/src/libdatastruct/avlnode_searchnode.c b/src/libdatastruct/avlnode_searchnode.c
index 4ab015c..40463c7 100644
--- a/src/libdatastruct/avlnode_searchnode.c
+++ b/src/libdatastruct/avlnode_searchnode.c
@@ -1,14 +1,15 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/functypes.h>
#include <skalibs/avlnode.h>
#include "avlnode-internal.h"
-unsigned int avlnode_searchnode (avlnode const *s, unsigned int max, unsigned int r, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+uint32_t avlnode_searchnode (avlnode const *s, uint32_t max, uint32_t r, void const *k, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
while (r < max)
{
- register int h = (*f)(k, (*dtok)(s[r].data, p), p) ;
+ int h = (*f)(k, (*dtok)(s[r].data, p), p) ;
if (!h) break ;
r = s[r].child[avlnode_ufroms(h)] ;
}
diff --git a/src/libdatastruct/avltree_delete.c b/src/libdatastruct/avltree_delete.c
index 682877c..04f6097 100644
--- a/src/libdatastruct/avltree_delete.c
+++ b/src/libdatastruct/avltree_delete.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/avlnode.h>
@@ -7,8 +8,8 @@
int avltree_delete (avltree *t, void const *k)
{
- unsigned int r = avltree_root(t) ;
- unsigned int i = avlnode_delete(avltree_nodes(t), avltree_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ;
+ uint32_t r = avltree_root(t) ;
+ uint32_t i = avlnode_delete(avltree_nodes(t), avltree_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ;
if (i >= avltree_totalsize(t)) return (errno = ESRCH, 0) ;
avltree_setroot(t, r) ;
if (!gensetdyn_delete(&t->x, i)) return 0 ;
diff --git a/src/libdatastruct/avltree_init.c b/src/libdatastruct/avltree_init.c
index b4bfbe5..9a92d08 100644
--- a/src/libdatastruct/avltree_init.c
+++ b/src/libdatastruct/avltree_init.c
@@ -1,15 +1,16 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/functypes.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/avlnode.h>
#include <skalibs/avltree.h>
-void avltree_init (avltree *t, unsigned int base, unsigned int fracnum, unsigned int fracden, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+void avltree_init (avltree *t, uint32_t base, uint32_t fracnum, uint32_t fracden, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
gensetdyn_init(&t->x, sizeof(avlnode), base, fracnum, fracden) ;
- t->root = (unsigned int)-1 ;
+ t->root = UINT32_MAX ;
t->dtok = dtok ;
t->kcmp = f ;
t->external = p ;
diff --git a/src/libdatastruct/avltree_insert.c b/src/libdatastruct/avltree_insert.c
index 308990a..d06da2b 100644
--- a/src/libdatastruct/avltree_insert.c
+++ b/src/libdatastruct/avltree_insert.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avltree.h>
-int avltree_insert (avltree_ref t, unsigned int d)
+int avltree_insert (avltree *t, uint32_t d)
{
- unsigned int i ;
+ uint32_t i ;
if (!avltree_newnode(t, d, &i)) return 0 ;
avltree_insertnode(t, i) ;
return 1 ;
diff --git a/src/libdatastruct/avltree_newnode.c b/src/libdatastruct/avltree_newnode.c
index 934da2c..07cb813 100644
--- a/src/libdatastruct/avltree_newnode.c
+++ b/src/libdatastruct/avltree_newnode.c
@@ -1,17 +1,18 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/gensetdyn.h>
#include <skalibs/avlnode.h>
#include <skalibs/avltree.h>
-int avltree_newnode (avltree *t, unsigned int data, unsigned int *i)
+int avltree_newnode (avltree *t, uint32_t data, uint32_t *i)
{
if (!gensetdyn_new(&t->x, i)) return 0 ;
{
- register avlnode *s = avltree_nodes(t) ;
+ avlnode *s = avltree_nodes(t) ;
s[*i].data = data ;
- s[*i].child[0] = s[*i].child[1] = (unsigned int)-1 ;
+ s[*i].child[0] = s[*i].child[1] = UINT32_MAX ;
s[*i].balance = 0 ;
}
return 1 ;
diff --git a/src/libdatastruct/avltreen_delete.c b/src/libdatastruct/avltreen_delete.c
index ecf6ea4..a154e65 100644
--- a/src/libdatastruct/avltreen_delete.c
+++ b/src/libdatastruct/avltreen_delete.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/genset.h>
#include <skalibs/avlnode.h>
@@ -7,8 +8,8 @@
int avltreen_delete (avltreen *t, void const *k)
{
- unsigned int r = avltreen_root(t) ;
- unsigned int i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ;
+ uint32_t r = avltreen_root(t) ;
+ uint32_t i = avlnode_delete(avltreen_nodes(t), avltreen_totalsize(t), &r, k, t->dtok, t->kcmp, t->external) ;
if (i >= avltreen_totalsize(t)) return (errno = ESRCH, 0) ;
avltreen_setroot(t, r) ;
if (!genset_delete(&t->x, i)) return 0 ;
diff --git a/src/libdatastruct/avltreen_init.c b/src/libdatastruct/avltreen_init.c
index b4172b8..d831610 100644
--- a/src/libdatastruct/avltreen_init.c
+++ b/src/libdatastruct/avltreen_init.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/functypes.h>
#include <skalibs/genset.h>
#include <skalibs/avlnode.h>
#include <skalibs/avltreen.h>
-void avltreen_init (avltreen *t, avlnode_ref storage, unsigned int *freelist, unsigned int size, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
+void avltreen_init (avltreen *t, avlnode *storage, uint32_t *freelist, uint32_t size, dtokfunc_t_ref dtok, cmpfunc_t_ref f, void *p)
{
GENSET_init(&t->x, avlnode, storage, freelist, size) ;
t->root = size ;
diff --git a/src/libdatastruct/avltreen_insert.c b/src/libdatastruct/avltreen_insert.c
index b3d24d0..5329340 100644
--- a/src/libdatastruct/avltreen_insert.c
+++ b/src/libdatastruct/avltreen_insert.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/avltreen.h>
-int avltreen_insert (avltreen *t, unsigned int d)
+int avltreen_insert (avltreen *t, uint32_t d)
{
- unsigned int i = avltreen_newnode(t, d) ;
+ uint32_t i = avltreen_newnode(t, d) ;
if (i >= avltreen_totalsize(t)) return 0 ;
avltreen_insertnode(t, i) ;
return 1 ;
diff --git a/src/libdatastruct/avltreen_newnode.c b/src/libdatastruct/avltreen_newnode.c
index 62b08e2..36b1ab6 100644
--- a/src/libdatastruct/avltreen_newnode.c
+++ b/src/libdatastruct/avltreen_newnode.c
@@ -1,15 +1,16 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/genset.h>
#include <skalibs/avlnode.h>
#include <skalibs/avltreen.h>
-unsigned int avltreen_newnode (avltreen *t, unsigned int d)
+uint32_t avltreen_newnode (avltreen *t, uint32_t d)
{
- register unsigned int i = genset_new(&t->x) ;
+ uint32_t i = genset_new(&t->x) ;
if (i < avltreen_totalsize(t))
{
- register avlnode *s = avltreen_nodes(t) ;
+ avlnode *s = avltreen_nodes(t) ;
s[i].data = d ;
s[i].child[0] = s[i].child[1] = avltreen_totalsize(t) ;
s[i].balance = 0 ;
diff --git a/src/libdatastruct/genset.c b/src/libdatastruct/genset.c
index c8fc36e..a4e48e0 100644
--- a/src/libdatastruct/genset.c
+++ b/src/libdatastruct/genset.c
@@ -1,25 +1,26 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/genset.h>
-void genset_init (genset *x, void *storage, unsigned int *freelist, unsigned int esize, unsigned int max)
+void genset_init (genset *x, void *storage, uint32_t *freelist, uint32_t esize, uint32_t max)
{
- register unsigned int i = 0 ;
+ uint32_t i = max ;
x->storage = (char *)storage ;
x->freelist = freelist ;
x->esize = esize ;
x->max = max ;
x->sp = max ;
- for (; i < max ; i++) freelist[i] = max - 1 - i ;
+ while (i--) freelist[i] = max - 1 - i ;
}
-unsigned int genset_new (genset *x)
+uint32_t genset_new (genset *x)
{
return x->sp ? x->freelist[--x->sp] : (errno = ENOSPC, x->max) ;
}
-int genset_delete (genset *x, unsigned int i)
+int genset_delete (genset *x, uint32_t i)
{
if ((i >= x->max) || (x->sp >= x->max)) return (errno = EINVAL, 0) ;
x->freelist[x->sp++] = i ;
diff --git a/src/libdatastruct/genset_iter_nocancel.c b/src/libdatastruct/genset_iter_nocancel.c
index f78945d..9f8ab28 100644
--- a/src/libdatastruct/genset_iter_nocancel.c
+++ b/src/libdatastruct/genset_iter_nocancel.c
@@ -1,13 +1,14 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/bitarray.h>
#include <skalibs/functypes.h>
#include <skalibs/genset.h>
-unsigned int genset_iter_nocancel (genset *g, unsigned int n, iterfunc_t_ref f, void *stuff)
+uint32_t genset_iter_nocancel (genset *g, uint32_t n, iterfunc_t_ref f, void *stuff)
{
unsigned char bits[bitarray_div8(n)] ;
- unsigned int i = 0, j = 0, m = genset_n(g) ;
+ uint32_t i = 0, j = 0, m = genset_n(g) ;
bitarray_setn(bits, 0, n) ;
for (; i < g->sp ; i++) if (g->freelist[i] < n) bitarray_clear(bits, g->freelist[i]) ;
for (i = 0 ; (i < n) && (j < m) ; i++) if (bitarray_peek(bits, i))
diff --git a/src/libdatastruct/genset_iter_withcancel.c b/src/libdatastruct/genset_iter_withcancel.c
index fa8074b..a8f9c86 100644
--- a/src/libdatastruct/genset_iter_withcancel.c
+++ b/src/libdatastruct/genset_iter_withcancel.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/functypes.h>
#include <skalibs/genset.h>
int genset_iter_withcancel (genset *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff)
{
- unsigned int n = genset_iter(g, f, stuff) ;
+ uint32_t n = genset_iter(g, f, stuff) ;
if (n < g->max)
{
int e = errno ;
diff --git a/src/libdatastruct/gensetdyn_delete.c b/src/libdatastruct/gensetdyn_delete.c
index cfa15cf..019760c 100644
--- a/src/libdatastruct/gensetdyn_delete.c
+++ b/src/libdatastruct/gensetdyn_delete.c
@@ -1,11 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-int gensetdyn_delete (gensetdyn *g, unsigned int i)
+int gensetdyn_delete (gensetdyn *g, uint32_t i)
{
return (i >= g->storage.len) ? (errno = EINVAL, 0) :
- genalloc_catb(unsigned int, &g->freelist, &i, 1) ;
+ genalloc_catb(uint32_t, &g->freelist, &i, 1) ;
}
diff --git a/src/libdatastruct/gensetdyn_free.c b/src/libdatastruct/gensetdyn_free.c
index b0e03ad..56b1fe4 100644
--- a/src/libdatastruct/gensetdyn_free.c
+++ b/src/libdatastruct/gensetdyn_free.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
@@ -7,6 +8,6 @@
void gensetdyn_free (gensetdyn *g)
{
stralloc_free(&g->storage) ;
- genalloc_free(unsigned int, &g->freelist) ;
+ genalloc_free(uint32_t, &g->freelist) ;
*g = gensetdyn_zero ;
}
diff --git a/src/libdatastruct/gensetdyn_init.c b/src/libdatastruct/gensetdyn_init.c
index 7cfdf86..a9eaa70 100644
--- a/src/libdatastruct/gensetdyn_init.c
+++ b/src/libdatastruct/gensetdyn_init.c
@@ -1,10 +1,11 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-void gensetdyn_init (gensetdyn *g, unsigned int esize, unsigned int base, unsigned int fracnum, unsigned int fracden)
+void gensetdyn_init (gensetdyn *g, uint32_t esize, uint32_t base, uint32_t fracnum, uint32_t fracden)
{
g->storage = stralloc_zero ;
g->freelist = genalloc_zero ;
diff --git a/src/libdatastruct/gensetdyn_iter.c b/src/libdatastruct/gensetdyn_iter.c
index b4e1638..c5bbcef 100644
--- a/src/libdatastruct/gensetdyn_iter.c
+++ b/src/libdatastruct/gensetdyn_iter.c
@@ -1,19 +1,22 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/bitarray.h>
#include <skalibs/functypes.h>
#include <skalibs/gensetdyn.h>
-unsigned int gensetdyn_iter_nocancel (gensetdyn *g, unsigned int n, iterfunc_t_ref f, void *stuff)
+uint32_t gensetdyn_iter_nocancel (gensetdyn *g, uint32_t n, iterfunc_t_ref f, void *stuff)
{
/*
XXX: we may be called by a freeing function, so we cannot alloc -
XXX: so pray that the bitarray fits in the stack.
*/
- unsigned char bits[bitarray_div8(g->storage.len)] ;
- unsigned int i = 0, j = 0 ;
- register unsigned int *fl = genalloc_s(unsigned int, &g->freelist) ;
- register unsigned int sp = genalloc_len(unsigned int, &g->freelist) ;
+ unsigned char bits[bitarray_div8(g->storage.len) ? bitarray_div8(g->storage.len) : 1] ;
+ size_t i = 0 ;
+ uint32_t j = 0 ;
+ uint32_t *fl = genalloc_s(uint32_t, &g->freelist) ;
+ size_t sp = genalloc_len(uint32_t, &g->freelist) ;
bitarray_setn(bits, 0, g->storage.len) ;
for (; i < sp ; i++) if (fl[i] < g->storage.len) bitarray_clear(bits, fl[i]) ;
diff --git a/src/libdatastruct/gensetdyn_iter_withcancel.c b/src/libdatastruct/gensetdyn_iter_withcancel.c
index 8dc2a18..07f0c52 100644
--- a/src/libdatastruct/gensetdyn_iter_withcancel.c
+++ b/src/libdatastruct/gensetdyn_iter_withcancel.c
@@ -1,12 +1,13 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
#include <skalibs/functypes.h>
#include <skalibs/gensetdyn.h>
int gensetdyn_iter_withcancel (gensetdyn *g, iterfunc_t_ref f, iterfunc_t_ref cancelf, void *stuff)
{
- unsigned int n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ;
+ uint32_t n = gensetdyn_iter_nocancel(g, gensetdyn_n(g), f, stuff) ;
if (n < gensetdyn_n(g))
{
int e = errno ;
diff --git a/src/libdatastruct/gensetdyn_new.c b/src/libdatastruct/gensetdyn_new.c
index 5e199b3..bf744d5 100644
--- a/src/libdatastruct/gensetdyn_new.c
+++ b/src/libdatastruct/gensetdyn_new.c
@@ -1,14 +1,16 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-int gensetdyn_new (gensetdyn *g, unsigned int *i)
+int gensetdyn_new (gensetdyn *g, uint32_t *i)
{
- register unsigned int n ;
- if (!genalloc_len(unsigned int, &g->freelist) && !gensetdyn_readyplus(g, 1)) return 0 ;
- n = genalloc_len(unsigned int, &g->freelist) ;
- *i = genalloc_s(unsigned int, &g->freelist)[n-1] ;
- genalloc_setlen(unsigned int, &g->freelist, n-1) ;
+ size_t n ;
+ if (!genalloc_len(uint32_t, &g->freelist) && !gensetdyn_readyplus(g, 1)) return 0 ;
+ n = genalloc_len(uint32_t, &g->freelist) ;
+ *i = genalloc_s(uint32_t, &g->freelist)[n-1] ;
+ genalloc_setlen(uint32_t, &g->freelist, n-1) ;
return 1 ;
}
diff --git a/src/libdatastruct/gensetdyn_ready.c b/src/libdatastruct/gensetdyn_ready.c
index 8418e1a..0bdcd0b 100644
--- a/src/libdatastruct/gensetdyn_ready.c
+++ b/src/libdatastruct/gensetdyn_ready.c
@@ -1,25 +1,26 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
-int gensetdyn_ready (gensetdyn *g, unsigned int n)
+int gensetdyn_ready (gensetdyn *g, uint32_t n)
{
int wasnull = !g->storage.s ;
- unsigned int i = g->storage.len ;
+ uint32_t i = g->storage.len ;
if (n < i) return 1 ;
n += g->base + (n * g->fracnum) / g->fracden ;
if (!stralloc_ready_tuned(&g->storage, n * g->esize, 0, 0, 1)) return 0 ;
- if (!genalloc_ready(unsigned int, &g->freelist, n))
+ if (!genalloc_ready(uint32_t, &g->freelist, n))
{
if (wasnull) stralloc_free(&g->storage) ;
return 0 ;
}
for (; i < n ; i++)
{
- unsigned int j = n - 1 - i + g->storage.len ;
- genalloc_catb(unsigned int, &g->freelist, &j, 1) ;
+ uint32_t j = n - 1 - i + g->storage.len ;
+ genalloc_catb(uint32_t, &g->freelist, &j, 1) ;
}
g->storage.len = n ;
return 1 ;