summaryrefslogtreecommitdiff
path: root/src/libstddjb/uint64_fmtlist_generic.c
blob: 6ea2762cdffe00f4e2df56b85d59b37de45a0b59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* ISC license. */

#include <skalibs/uint64.h>

size_t uint64_fmtlist_generic (char *s, void const *tab, size_t n, uint8_t base, uint64_t (*get)(void const *, size_t))
{
  size_t i = 0, len = 0 ;
  for (; i < n ; i++)
  {
    size_t w = uint64_fmt_generic(s, (*get)(tab, i), base) ;
    len += w ;
    if (s) s += w ;
    if (i < n-1) { len++ ; if (s) *s++ = ',' ; }
  }
  return len ;
}