Skip to content

Commit

Permalink
[ruby/prism] Additional fix of adding x prefix after rebase with ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
hasumikin authored and matzbot committed Mar 4, 2024
1 parent 54f2754 commit b95e2cd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions prism/static_literals.c
Expand Up @@ -135,7 +135,7 @@ pm_node_hash_insert(pm_node_hash_t *hash, const pm_parser_t *parser, pm_node_t *
if (hash->size * 2 >= hash->capacity) {
// First, allocate space for the new node list.
uint32_t new_capacity = hash->capacity == 0 ? 4 : hash->capacity * 2;
pm_node_t **new_nodes = calloc(new_capacity, sizeof(pm_node_t *));
pm_node_t **new_nodes = xcalloc(new_capacity, sizeof(pm_node_t *));
if (new_nodes == NULL) return NULL;

// It turns out to be more efficient to mask the hash value than to use
Expand All @@ -155,7 +155,7 @@ pm_node_hash_insert(pm_node_hash_t *hash, const pm_parser_t *parser, pm_node_t *
}

// Finally, free the old node list and update the hash.
free(hash->nodes);
xfree(hash->nodes);
hash->nodes = new_nodes;
hash->capacity = new_capacity;
}
Expand Down Expand Up @@ -188,7 +188,7 @@ pm_node_hash_insert(pm_node_hash_t *hash, const pm_parser_t *parser, pm_node_t *
*/
static void
pm_node_hash_free(pm_node_hash_t *hash) {
if (hash->capacity > 0) free(hash->nodes);
if (hash->capacity > 0) xfree(hash->nodes);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion prism/util/pm_constant_pool.c
Expand Up @@ -18,7 +18,7 @@ bool
pm_constant_id_list_append(pm_constant_id_list_t *list, pm_constant_id_t id) {
if (list->size >= list->capacity) {
list->capacity = list->capacity == 0 ? 8 : list->capacity * 2;
list->ids = (pm_constant_id_t *) realloc(list->ids, sizeof(pm_constant_id_t) * list->capacity);
list->ids = (pm_constant_id_t *) xrealloc(list->ids, sizeof(pm_constant_id_t) * list->capacity);
if (list->ids == NULL) return false;
}

Expand Down

0 comments on commit b95e2cd

Please sign in to comment.