Modular SHell
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
msh/fstr.c

23 lines
387 B

#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--;
}