stralloc_catb.c
author tomas@localhost
Thu, 01 Nov 2007 14:46:11 +0100
changeset 0 c045670f36e9
permissions -rw-r--r--
Imported queue-fix-1.4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     1
#include "stralloc.h"
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     2
#include "byte.h"
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     3
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     4
int stralloc_catb(sa,s,n)
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     5
stralloc *sa;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     6
char *s;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     7
unsigned int n;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     8
{
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
     9
  if (!sa->s) return stralloc_copyb(sa,s,n);
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    10
  if (!stralloc_readyplus(sa,n + 1)) return 0;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    11
  byte_copy(sa->s + sa->len,n,s);
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    12
  sa->len += n;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    13
  sa->s[sa->len] = 'Z'; /* ``offensive programming'' */
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    14
  return 1;
c045670f36e9 Imported queue-fix-1.4
tomas@localhost
parents:
diff changeset
    15
}