nightmaremail

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

stralloc_opyb.c (393B)


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