summaryrefslogtreecommitdiff
path: root/bittorrent/mbtstr/src/pushc.c
blob: d63d3d06759c75817e4a478ab6409b6def738a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <stdlib.h>

#include "mbtstr/str.h"

bool mbt_str_pushc(struct mbt_str *str, char c)
{
    str->size += 1;
    if (str->size >= str->capacity)
    {
        str->capacity = str->size;
        str->data = realloc(str->data, str->capacity + 1);
        if (str->data == NULL)
            return false;
    }
    str->data[str->size - 1] = c;
    str->data[str->size] = 0;
    return true;
}