mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Add asserts to address map / address set
This commit is contained in:
parent
95868c70a2
commit
4be3e69ac1
2 changed files with 6 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "address-hash.h"
|
#include "address-hash.h"
|
||||||
|
#include "gc-assert.h"
|
||||||
|
|
||||||
struct hash_map_entry {
|
struct hash_map_entry {
|
||||||
uintptr_t k;
|
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) {
|
static void hash_map_init(struct hash_map *map, size_t size) {
|
||||||
map->size = size;
|
map->size = size;
|
||||||
map->data = malloc(sizeof(struct hash_map_entry) * size);
|
map->data = malloc(sizeof(struct hash_map_entry) * size);
|
||||||
|
if (!map->data) GC_CRASH();
|
||||||
map->bits = malloc(size / 8);
|
map->bits = malloc(size / 8);
|
||||||
|
if (!map->bits) GC_CRASH();
|
||||||
hash_map_clear(map);
|
hash_map_clear(map);
|
||||||
}
|
}
|
||||||
static void hash_map_destroy(struct hash_map *map) {
|
static void hash_map_destroy(struct hash_map *map) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "address-hash.h"
|
#include "address-hash.h"
|
||||||
|
#include "gc-assert.h"
|
||||||
|
|
||||||
struct hash_set {
|
struct hash_set {
|
||||||
uintptr_t *data;
|
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) {
|
static void hash_set_init(struct hash_set *set, size_t size) {
|
||||||
set->size = size;
|
set->size = size;
|
||||||
set->data = malloc(sizeof(uintptr_t) * size);
|
set->data = malloc(sizeof(uintptr_t) * size);
|
||||||
|
if (!set->data) GC_CRASH();
|
||||||
set->bits = malloc(size / 8);
|
set->bits = malloc(size / 8);
|
||||||
|
if (!set->bits) GC_CRASH();
|
||||||
hash_set_clear(set);
|
hash_set_clear(set);
|
||||||
}
|
}
|
||||||
static void hash_set_destroy(struct hash_set *set) {
|
static void hash_set_destroy(struct hash_set *set) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue