summaryrefslogtreecommitdiff
path: root/src/libdatastruct/genset.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-22 10:03:15 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-22 10:03:15 +0000
commita5079576ae9007fb1ca7ebcc911b5fb035cd2d06 (patch)
tree70f4014dd37d780dfb45182d26092cb1998d4eec /src/libdatastruct/genset.c
parent49d8fa1058aaf23c29e074b2314492ae40d2f557 (diff)
downloadskalibs-a5079576ae9007fb1ca7ebcc911b5fb035cd2d06.tar.xz
Types change: switch libdatastruct to uint32_t
Still needs to be reviewed.
Diffstat (limited to 'src/libdatastruct/genset.c')
-rw-r--r--src/libdatastruct/genset.c11
1 files changed, 6 insertions, 5 deletions
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 ;