Skip to content

Commit

Permalink
chore: remove a little bit of duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
Conni2461 committed Feb 18, 2022
1 parent 325a9f9 commit 862569e
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/fzf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,19 @@
free((obj).data); \
}

#define gen_slice(name, type) \
#define gen_simple_slice(name, type) \
typedef struct { \
type *data; \
size_t size; \
} name##_slice_t; \
static name##_slice_t slice_##name(type *input, size_t from, size_t to) { \
return (name##_slice_t){.data = input + from, .size = to - from}; \
} \
static name##_slice_t slice_##name##_right(type *input, size_t to) { \
return slice_##name(input, 0, to); \
}

#define gen_simple_slice(name, type) \
typedef struct { \
type *data; \
size_t size; \
} name##_slice_t; \
static name##_slice_t slice_##name(type *input, size_t from, size_t to) { \
return (name##_slice_t){.data = input + from, .size = to - from}; \
#define gen_slice(name, type) \
gen_simple_slice(name, type); \
static name##_slice_t slice_##name##_right(type *input, size_t to) { \
return slice_##name(input, 0, to); \
}

gen_slice(i16, int16_t);
Expand Down

0 comments on commit 862569e

Please sign in to comment.