24 lines
387 B
C
24 lines
387 B
C
|
|
#define _POSIX_C_SOURCE 200809l
|
||
|
|
|
||
|
|
#include <stdlib.h>
|
||
|
|
|
||
|
|
#include "fstr.h"
|
||
|
|
#include "config.h"
|
||
|
|
|
||
|
|
void fstr_add_space(fstr_t *fs)
|
||
|
|
{
|
||
|
|
erealloc(fs->s, fs->len + fs->space + DEF_CHUNKSIZE + 1);
|
||
|
|
fs->space += DEF_CHUNKSIZE;
|
||
|
|
}
|
||
|
|
|
||
|
|
void fstr_append_char(fstr_t *fs, char c)
|
||
|
|
{
|
||
|
|
if (!fs)
|
||
|
|
return;
|
||
|
|
if (fs->space < 1)
|
||
|
|
fstr_add_space(fs);
|
||
|
|
fs->s[fs->len++] = c;
|
||
|
|
fs->s[fs->len] = '\0';
|
||
|
|
fs->space--;
|
||
|
|
}
|