suitcase

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

stralloc_opyb.c (406B)


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