~kdsch/sampler

c1edce67de71adfb4594ed9cc3d9a7c5ac5dd32a — Karl Schultheisz 2 months ago e653718
posix/table-generator: add assertions and consts

Just to clarify our intent.
1 files changed, 5 insertions(+), 2 deletions(-)

M posix/table-generator/main.c
M posix/table-generator/main.c => posix/table-generator/main.c +5 -2
@@ 36,7 36,8 @@ table_render(const struct table *t, FILE *out)
static int
table_grow(struct table *t)
{
	size_t newcap = t->cap ? 2 * t->cap : 48;
	assert(t);
	const size_t newcap = t->cap ? 2 * t->cap : 48;
	int16_t *frames = realloc(t->frames, sizeof(t->frames[0]) * newcap);

	if (!frames) {


@@ 77,6 78,7 @@ table_room(const struct table *t)
static void
table_load(struct table *t)
{
	assert(t);
	SF_INFO info = {.format = 0};
	SNDFILE *f = sf_open(t->path, SFM_READ, &info);



@@ 93,7 95,8 @@ table_load(struct table *t)
			table_grow(t);
		}

		size_t count = sf_read_short(f, table_end(t), table_room(t));
		const size_t count =
			sf_read_short(f, table_end(t), table_room(t));
		t->len += count;

		if (count < table_room(t)) {