diff options
-rw-r--r-- | source/kit/file.c | 8 | ||||
-rw-r--r-- | source/kit/input_buffer.c | 6 | ||||
-rw-r--r-- | source/kit/status.h | 2 | ||||
-rw-r--r-- | source/kit/string_builder.h | 4 | ||||
-rw-r--r-- | source/kit/test.h | 10 | ||||
-rw-r--r-- | source/kit/xml.c | 19 |
6 files changed, 28 insertions, 21 deletions
diff --git a/source/kit/file.c b/source/kit/file.c index 76d3249..3eafc70 100644 --- a/source/kit/file.c +++ b/source/kit/file.c @@ -465,7 +465,7 @@ kit_path_list_t kit_folder_enum(kit_str_t path, i64 n = result.files.size; DA_RESIZE(result.files, n + 1); if (result.files.size != n + 1) { - result.status = KIT_ERROR_BAD_ALLOC; + result.status = KIT_ERROR_OUT_OF_MEMORY; break; } @@ -473,7 +473,7 @@ kit_path_list_t kit_folder_enum(kit_str_t path, DA_INIT(result.files.values[n], size, alloc); if (result.files.values[n].size != size) { DA_RESIZE(result.files, n); - result.status = KIT_ERROR_BAD_ALLOC; + result.status = KIT_ERROR_OUT_OF_MEMORY; break; } @@ -499,7 +499,7 @@ kit_path_list_t kit_folder_enum(kit_str_t path, i64 n = result.files.size; DA_RESIZE(result.files, n + 1); if (result.files.size != n + 1) { - result.status = KIT_ERROR_BAD_ALLOC; + result.status = KIT_ERROR_OUT_OF_MEMORY; break; } @@ -507,7 +507,7 @@ kit_path_list_t kit_folder_enum(kit_str_t path, DA_INIT(result.files.values[n], size, alloc); if (result.files.values[n].size != size) { DA_RESIZE(result.files, n); - result.status = KIT_ERROR_BAD_ALLOC; + result.status = KIT_ERROR_OUT_OF_MEMORY; break; } diff --git a/source/kit/input_buffer.c b/source/kit/input_buffer.c index db7e156..59298c8 100644 --- a/source/kit/input_buffer.c +++ b/source/kit/input_buffer.c @@ -19,7 +19,7 @@ static s32 kit_buf_adjust_(kit_input_buffer_t *buf, i64 size) { DA_RESIZE(buf->data, size); if (buf->data.size != size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; str_t destination = { .size = size - offset, .values = buf->data.values + offset }; @@ -27,7 +27,7 @@ static s32 kit_buf_adjust_(kit_input_buffer_t *buf, i64 size) { DA_RESIZE(buf->data, offset + n); if (buf->data.size != offset + n) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; return KIT_OK; } @@ -118,7 +118,7 @@ kit_ib_token_t kit_ib_read(kit_ib_token_t tok, i64 size) { } else { \ DA_INIT(cache_dynamic, data.size, tok.buffer->data.alloc); \ if (cache_dynamic.size != data.size) { \ - (res_).status |= KIT_ERROR_BAD_ALLOC; \ + (res_).status |= KIT_ERROR_OUT_OF_MEMORY; \ return (res_); \ } \ memcpy(cache_dynamic.values, data.values, data.size); \ diff --git a/source/kit/status.h b/source/kit/status.h index 7ea1c4d..88eb5e0 100644 --- a/source/kit/status.h +++ b/source/kit/status.h @@ -8,7 +8,7 @@ enum { KIT_OK = 0, KIT_PARSING_FAILED = 1, - KIT_ERROR_BAD_ALLOC = (1 << 1), + KIT_ERROR_OUT_OF_MEMORY = (1 << 1), KIT_ERROR_INVALID_ARGUMENT = (1 << 2), KIT_ERROR_MKDIR_FAILED = (1 << 3), KIT_ERROR_RMDIR_FAILED = (1 << 4), diff --git a/source/kit/string_builder.h b/source/kit/string_builder.h index c869afb..23eda65 100644 --- a/source/kit/string_builder.h +++ b/source/kit/string_builder.h @@ -56,7 +56,7 @@ static s32 kit_str_append(kit_str_builder_t *a, kit_str_t b) { i64 n = a->size; KIT_DA_RESIZE(*a, n + b.size); if (a->size != n + b.size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; memcpy(a->values + n, b.values, b.size); return KIT_OK; } @@ -71,7 +71,7 @@ static s32 kit_str_insert(kit_str_builder_t *a, i64 index, i64 n = a->size; KIT_DA_RESIZE(*a, n + b.size); if (a->size != n + b.size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; if (index < n) memmove(a->values + (index + b.size), a->values + index, n - index); diff --git a/source/kit/test.h b/source/kit/test.h index 24a25c9..efbce5f 100644 --- a/source/kit/test.h +++ b/source/kit/test.h @@ -505,7 +505,8 @@ int kit_run_tests(int argc, char **argv) { for (; s[k] != '\0' && kit_tests_list.v[j].test_file[k] != '\0' && s[k] == kit_tests_list.v[j].test_file[k]; - k++) { } + k++) { + } if (file_root == -1 || file_root > k) file_root = k; } @@ -725,7 +726,7 @@ int kit_run_tests(int argc, char **argv) { quiet || printf("FAILED\n"); } - no_color || kit_print_color_(kit_white_); + no_color || kit_print_color_(kit_light_); quiet || printf("\n"); return status; } @@ -881,7 +882,8 @@ int kit_run_benchmarks(int argc, char **argv) { int k = 0; for (; s[k] != '\0' && bench->bench_file[k] != '\0' && s[k] == bench->bench_file[k]; - k++) { } + k++) { + } if (file_root == -1 || file_root > k) file_root = k; } @@ -1099,7 +1101,7 @@ int kit_run_benchmarks(int argc, char **argv) { printf("DONE WITH ERRORS\n"); } - no_color || kit_print_color_(kit_white_); + no_color || kit_print_color_(kit_light_); printf("\n"); return status; } diff --git a/source/kit/xml.c b/source/kit/xml.c index 8d22bf3..0d8378c 100644 --- a/source/kit/xml.c +++ b/source/kit/xml.c @@ -22,7 +22,7 @@ static s32 kit_xml_alloc_and_unescape_(str_builder_t *dst, str_t str, DA_INIT(*dst, str.size, alloc); if (dst->size != str.size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; dst->size = 0; @@ -127,7 +127,8 @@ static ib_token_t kit_xml_parse_text_(ib_token_t begin, assert(dst->size == last.size); if (dst->size != last.size) - last.status |= KIT_ERROR_BAD_ALLOC; + last.status |= KIT_ERROR_OUT_OF_MEMORY +; else if (last.size > 0) memcpy(dst->values, ib_str(last).values, last.size); @@ -147,7 +148,8 @@ static ib_token_t kit_xml_parse_text_(ib_token_t begin, assert(dst->size == n + next_text.size); if (dst->size != n + next_text.size) - next_text.status |= KIT_ERROR_BAD_ALLOC; + next_text.status |= KIT_ERROR_OUT_OF_MEMORY + ; else memcpy(dst->values + n, ib_str(next_text).values, ib_str(next_text).size); @@ -246,7 +248,8 @@ static kit_xml_intermediate_t kit_xml_parse_buf_( assert(tag.properties.size == n + 1); if (tag.properties.size != n + 1) { - last.status |= KIT_ERROR_BAD_ALLOC; + last.status |= KIT_ERROR_OUT_OF_MEMORY + ; DA_DESTROY(tag.properties); } else { last.status |= kit_xml_alloc_and_unescape_( @@ -303,7 +306,8 @@ static kit_xml_intermediate_t kit_xml_parse_buf_( assert(res.tags.size == n + 1); if (res.tags.size != n + 1) { - last.status |= KIT_ERROR_BAD_ALLOC; + last.status |= KIT_ERROR_OUT_OF_MEMORY + ; xml_destroy(&tag); } else { last.status |= kit_xml_alloc_and_unescape_( @@ -390,7 +394,7 @@ static s32 kit_xml_append_text_(str_builder_t *buf, xml_t *xml) { assert(buf->size == n + xml->text.size); if (buf->size != n + xml->text.size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY; if (xml->text.size > 0) memcpy(buf->values + n, xml->text.values, xml->text.size); @@ -410,7 +414,8 @@ static s32 kit_xml_append_text_(str_builder_t *buf, xml_t *xml) { assert(buf->size == n + tail.size); if (buf->size != n + tail.size) - return KIT_ERROR_BAD_ALLOC; + return KIT_ERROR_OUT_OF_MEMORY +; if (tail.size > 0) memcpy(buf->values + n, tail.values, tail.size); |