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

#include "mbtstr/str.h"

bool mbt_str_ctor(struct mbt_str *str, size_t capacity)
{
    str->size = 0;
    str->capacity = capacity;
    if (str->capacity == 0)
    {
        str->data = NULL;
        return true;
    }
    str->data = calloc(capacity + 1, 1);
    if (str->data == NULL)
        return false;
    return true;
}