1 /* ISC license. */
2 
3 #include <string.h>
4 #include <errno.h>
5 #include <skalibs/stralloc.h>
6 
stralloc_insertb(stralloc * sa,size_t offset,char const * s,size_t n)7 int stralloc_insertb (stralloc *sa, size_t offset, char const *s, size_t n)
8 {
9   if (offset > sa->len) return (errno = EINVAL, 0) ;
10   if (!stralloc_readyplus(sa, n)) return 0 ;
11   memmove(sa->s + offset + n, sa->s + offset, sa->len - offset) ;
12   sa->len += n ;
13   memmove(sa->s + offset, s, n) ;
14   return 1 ;
15 }
16