Merge pull request #1881 from mattmassicotte/fix/array-integer-sizing

Explicit integer sizes for array capacity
This commit is contained in:
Max Brunsfeld 2022-09-21 20:17:28 -07:00 committed by GitHub
commit d62adbe3a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View file

@ -170,10 +170,10 @@ static inline void array__swap(VoidArray *self, VoidArray *other) {
*self = swap;
}
static inline void array__grow(VoidArray *self, size_t count, size_t element_size) {
size_t new_size = self->size + count;
static inline void array__grow(VoidArray *self, uint32_t count, size_t element_size) {
uint32_t new_size = self->size + count;
if (new_size > self->capacity) {
size_t new_capacity = self->capacity * 2;
uint32_t new_capacity = self->capacity * 2;
if (new_capacity < 8) new_capacity = 8;
if (new_capacity < new_size) new_capacity = new_size;
array__reserve(self, element_size, new_capacity);

View file

@ -1918,11 +1918,11 @@ static TSQueryError ts_query__parse_string_literal(
prev_position = stream->input + stream->next_size;
} else {
if (stream->next == '\\') {
array_extend(&self->string_buffer, (stream->input - prev_position), prev_position);
array_extend(&self->string_buffer, (uint32_t)(stream->input - prev_position), prev_position);
prev_position = stream->input + 1;
is_escaped = true;
} else if (stream->next == '"') {
array_extend(&self->string_buffer, (stream->input - prev_position), prev_position);
array_extend(&self->string_buffer, (uint32_t)(stream->input - prev_position), prev_position);
stream_advance(stream);
return TSQueryErrorNone;
} else if (stream->next == '\n') {
@ -3669,7 +3669,7 @@ static inline bool ts_query_cursor__advance(
} else {
LOG(" finish pattern %u\n", state->pattern_index);
array_push(&self->finished_states, *state);
array_erase(&self->states, state - self->states.contents);
array_erase(&self->states, (uint32_t)(state - self->states.contents));
did_match = true;
i--;
}

View file

@ -326,7 +326,7 @@ inline StackSliceArray stack__iter(
bool include_subtrees = false;
if (goal_subtree_count >= 0) {
include_subtrees = true;
array_reserve(&iterator.subtrees, ts_subtree_alloc_size(goal_subtree_count) / sizeof(Subtree));
array_reserve(&iterator.subtrees, (uint32_t)ts_subtree_alloc_size(goal_subtree_count) / sizeof(Subtree));
}
array_push(&self->iterators, iterator);