suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

stralloc_catb.c (591B)


      1 #include "ta_stralloc/stralloc.h"
      2 #include "byte.h"
      3 #include "error.h"
      4 #include "oflops.h"
      5 
      6 int stralloc_catb(stralloc *sa, char *s, unsigned int n) // PTYPE
      7 {
      8   unsigned int i;
      9   if (!sa->s) return stralloc_copyb(sa,s,n);
     10   if (__builtin_add_overflow(n, 1, &i)) {
     11     errno = error_nomem;
     12     return 0;
     13   }
     14   if (!stralloc_readyplus(sa,i)) return 0;
     15   byte_copy(sa->s + sa->len,n,s);
     16   sa->len += n;
     17   sa->s[sa->len] = 'Z'; /* ``offensive programming'' */
     18   /* Lightning NOTE: Shouldn't that be a nullis, so I can feed sa->s into things that need a null-terminated string? */
     19   return 1;
     20 }