Logo Search packages:      
Sourcecode: bglibs version File versions

int str_joinb ( str s,
char  sep,
const char *  in,
unsigned  len 
)

Join a binary block to this string

Definition at line 34 of file join.c.

References len, s, and str_realloc.

Referenced by str_join(), and str_joins().

{
  unsigned len1;
  unsigned off2;
  unsigned len2;
  
  len1 = s->len;
  while (len1 > 0 && s->s[len1-1] == sep) --len1;
  
  off2 = 0;
  while (off2 < len && in[off2] == sep) ++off2;
  len2 = len - off2;
  
  if (!str_realloc(s, len1+1+len2)) return 0;
  
  s->s[len1++] = sep;
  memcpy(s->s+len1, in+off2, len2);
  s->len = len1 + len2;
  s->s[s->len] = 0;
  return 1;
}


Generated by  Doxygen 1.6.0   Back to index