about summary refs log tree commit diff
path: root/src/libdatastruct/gensetdyn_new.c
blob: 66d3550199fd6cff9b725d81e6be26f66b0ee966 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ISC license. */

#include <sys/types.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 ;
}