stralloc_catb.c (458B)
1 #include "stralloc.h" 2 #include "byte.h" 3 #include "error.h" 4 #include "oflops.h" 5 6 int stralloc_catb(sa,s,n) 7 stralloc *sa; 8 char *s; 9 unsigned int n; 10 { 11 unsigned int i; 12 if (!sa->s) return stralloc_copyb(sa,s,n); 13 if (__builtin_add_overflow(n, 1, &i)) { 14 errno = error_nomem; 15 return 0; 16 } 17 if (!stralloc_readyplus(sa,i)) return 0; 18 byte_copy(sa->s + sa->len,n,s); 19 sa->len += n; 20 sa->s[sa->len] = 'Z'; /* ``offensive programming'' */ 21 return 1; 22 }