summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 09:51:58 +0400
committerMitya Selivanov <0x7fffff@guattari.ru>2022-08-07 09:51:58 +0400
commitccf5e49b969c7643cd67ac678a7f13f4639db745 (patch)
tree0da865cff3870f64c62b570791915996dc713ace /source
parent8589d6ff0c31701adfb9e18f46da471bbcf36020 (diff)
downloadkit-ccf5e49b969c7643cd67ac678a7f13f4639db745.zip
Refactor
Diffstat (limited to 'source')
-rw-r--r--source/kit/input_stream.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/source/kit/input_stream.c b/source/kit/input_stream.c
index 64a305e..89be44c 100644
--- a/source/kit/input_stream.c
+++ b/source/kit/input_stream.c
@@ -2,7 +2,7 @@
#include <string.h>
-enum { input_stream_cstr };
+enum { input_stream_str };
typedef struct {
ptrdiff_t type;
@@ -13,9 +13,9 @@ typedef struct {
ptrdiff_t type;
kit_allocator_t alloc;
kit_str_t string;
-} kit_is_state_cstr_t;
+} kit_is_state_str_t;
-static _Bool check_type(void *state, ptrdiff_t type) {
+static int check_type(void *state, ptrdiff_t type) {
kit_is_state_basic_t *basic = (kit_is_state_basic_t *) state;
return basic != NULL && basic->type == type;
}
@@ -26,14 +26,14 @@ static ptrdiff_t min(ptrdiff_t a, ptrdiff_t b) {
return b;
}
-static ptrdiff_t read_cstr(void *state, kit_out_str_t destination) {
- if (!check_type(state, input_stream_cstr))
+static ptrdiff_t read_str(void *state, kit_out_str_t destination) {
+ if (!check_type(state, input_stream_str))
return 0;
- kit_is_state_cstr_t *cstr = (kit_is_state_cstr_t *) state;
- ptrdiff_t size = min(destination.size, cstr->string.size);
- memcpy(destination.values, cstr->string.values, size);
- cstr->string.values += size;
- cstr->string.size -= size;
+ kit_is_state_str_t *str = (kit_is_state_str_t *) state;
+ ptrdiff_t size = min(destination.size, str->string.size);
+ memcpy(destination.values, str->string.values, size);
+ str->string.values += size;
+ str->string.size -= size;
return size;
}
@@ -41,15 +41,15 @@ kit_is_handle_t kit_is_wrap_string(kit_str_t string,
kit_allocator_t alloc) {
kit_is_handle_t in;
memset(&in, 0, sizeof in);
- kit_is_state_cstr_t *state = (kit_is_state_cstr_t *) alloc.allocate(
- alloc.state, sizeof(kit_is_state_cstr_t));
+ kit_is_state_str_t *state = (kit_is_state_str_t *) alloc.allocate(
+ alloc.state, sizeof(kit_is_state_str_t));
if (state != NULL) {
memset(state, 0, sizeof *state);
- state->type = input_stream_cstr;
+ state->type = input_stream_str;
state->string = string;
state->alloc = alloc;
in.state = state;
- in.read = read_cstr;
+ in.read = read_str;
}
return in;
}