diff options
Diffstat (limited to 'bytecode/slice.c')
| -rw-r--r-- | bytecode/slice.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/bytecode/slice.c b/bytecode/slice.c new file mode 100644 index 0000000..c7b2820 --- /dev/null +++ b/bytecode/slice.c @@ -0,0 +1,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 }; +} |
