diff options
Diffstat (limited to 'bittorrent/mbtstr/src/ctor.c')
| -rw-r--r-- | bittorrent/mbtstr/src/ctor.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bittorrent/mbtstr/src/ctor.c b/bittorrent/mbtstr/src/ctor.c new file mode 100644 index 0000000..5354f88 --- /dev/null +++ b/bittorrent/mbtstr/src/ctor.c @@ -0,0 +1,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; +} |
