Skip to content

Commit bd3914e

Browse files
committed
handle ENOMEM for dropping memory in regions_grow
1 parent eea522b commit bd3914e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

h_malloc.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,8 +1074,13 @@ static int regions_grow(void) {
10741074
}
10751075
}
10761076

1077-
memory_map_fixed(ra->regions, ra->total * sizeof(struct region_metadata));
1078-
memory_set_name(ra->regions, ra->total * sizeof(struct region_metadata), "malloc allocator_state");
1077+
if (memory_map_fixed(ra->regions, ra->total * sizeof(struct region_metadata))) {
1078+
if (memory_purge(ra->regions, ra->total * sizeof(struct region_metadata))) {
1079+
memset(ra->regions, 0, ra->total * sizeof(struct region_metadata));
1080+
}
1081+
} else {
1082+
memory_set_name(ra->regions, ra->total * sizeof(struct region_metadata), "malloc allocator_state");
1083+
}
10791084
ra->free = ra->free + ra->total;
10801085
ra->total = newtotal;
10811086
ra->regions = p;

0 commit comments

Comments
 (0)