aboutsummaryrefslogtreecommitdiff
path: root/lib/bob/u8strinit.c
blob: 60423c120354d86c454f09f84c5fc57f63184884 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdlib.h>

#include "bob.h"

struct u8str *
u8strinit(struct u8str *b, size_t n)
{
	if (n) {
		if (!(b->p = malloc(n)))
			return nullptr;
	} else
		b->p = nullptr;
	b->len = 0;
	b->cap = n;
	return b;
}