summaryrefslogtreecommitdiffstats
path: root/bytecode/slice.c
blob: c7b2820bcb26b57d21c90eea17c609dd1c958bcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <assert.h>

#include "slice.h"

struct slice slice(struct slice a, size_t i, size_t j)
{
	assert(i <= a.size && j <= a.size && i <= j);
	return (struct slice) { .size = j - i, .buf = a.buf + i };
}

struct slice slice1(struct slice a, size_t i)
{
	assert(i <= a.size);
	return (struct slice) { .size = a.size - i, .buf = a.buf + i };
}