|
|
|
@ -86,7 +86,18 @@ CSTRING *snew(size_t s) {
|
|
|
|
|
return cs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSTRING *sadd(CSTRING *s, char *a) {
|
|
|
|
|
CSTRING *sadd(CSTRING *s, char *a)
|
|
|
|
|
{
|
|
|
|
|
size_t len = strlen(a);
|
|
|
|
|
|
|
|
|
|
if(!s) return NULL;
|
|
|
|
|
if(!a || !len) return s;
|
|
|
|
|
|
|
|
|
|
return snadd(s, a, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CSTRING *snadd(CSTRING *s, char *a, size_t len)
|
|
|
|
|
{
|
|
|
|
|
size_t alen;
|
|
|
|
|
char *newbase;
|
|
|
|
|
|
|
|
|
@ -100,7 +111,7 @@ CSTRING *sadd(CSTRING *s, char *a) {
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
alen = strlen(a);
|
|
|
|
|
alen = len;
|
|
|
|
|
|
|
|
|
|
if (s->curlen + alen >= s->len) {
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
@ -125,9 +136,10 @@ CSTRING *sadd(CSTRING *s, char *a) {
|
|
|
|
|
s->base = newbase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memcpy(&s->base[s->curlen],a,alen);
|
|
|
|
|
memcpy(&s->base[s->curlen], a, alen);
|
|
|
|
|
s->curlen += alen;
|
|
|
|
|
s->base[s->curlen] = 0;
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|