From 4be3e69ac130a8d8385dfba05a674d863a91b044 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 6 Jan 2025 15:49:59 +0100 Subject: [PATCH] Add asserts to address map / address set --- src/address-map.h | 3 +++ src/address-set.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/address-map.h b/src/address-map.h index 4b6b0c47f..57c2a0a04 100644 --- a/src/address-map.h +++ b/src/address-map.h @@ -6,6 +6,7 @@ #include #include "address-hash.h" +#include "gc-assert.h" struct hash_map_entry { uintptr_t k; @@ -28,7 +29,9 @@ static void hash_map_clear(struct hash_map *map) { static void hash_map_init(struct hash_map *map, size_t size) { map->size = size; map->data = malloc(sizeof(struct hash_map_entry) * size); + if (!map->data) GC_CRASH(); map->bits = malloc(size / 8); + if (!map->bits) GC_CRASH(); hash_map_clear(map); } static void hash_map_destroy(struct hash_map *map) { diff --git a/src/address-set.h b/src/address-set.h index 74bc08888..b1c27fa41 100644 --- a/src/address-set.h +++ b/src/address-set.h @@ -6,6 +6,7 @@ #include #include "address-hash.h" +#include "gc-assert.h" struct hash_set { uintptr_t *data; @@ -23,7 +24,9 @@ static void hash_set_clear(struct hash_set *set) { static void hash_set_init(struct hash_set *set, size_t size) { set->size = size; set->data = malloc(sizeof(uintptr_t) * size); + if (!set->data) GC_CRASH(); set->bits = malloc(size / 8); + if (!set->bits) GC_CRASH(); hash_set_clear(set); } static void hash_set_destroy(struct hash_set *set) {