summaryrefslogtreecommitdiff
path: root/src/libbiguint/bu_copy.c
blob: 0c64417ca41a5e758b6ba19605954d9e8058b38d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* ISC license. */

#include <skalibs/bsdsnowflake.h>
#include <errno.h>
#include <skalibs/biguint.h>

int bu_copy (uint32_t *b, unsigned int bn, uint32_t const *a, unsigned int an)
{
  unsigned int alen = bu_len(a, an) ;
  if (bn < alen)
  {
    bu_copy_internal(b, a, bn) ;
    return (errno = EOVERFLOW, 0) ;
  }
  bu_copy_internal(b, a, alen) ;
  bu_zero(b + alen, bn - alen) ;
  return 1 ;
}