blob: bf744d5e52ae9efd353677458880fac5b8a298fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/* ISC license. */
#include <sys/types.h>
#include <stdint.h>
#include <skalibs/genalloc.h>
#include <skalibs/gensetdyn.h>
int gensetdyn_new (gensetdyn *g, uint32_t *i)
{
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 ;
}
|