Skip to content

Commit d6126a3

Browse files
committed
consistently use bool for reporting out-of-memory
1 parent bd3914e commit d6126a3

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

h_malloc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,26 +1041,26 @@ static void regions_quarantine_deallocate_pages(void *p, size_t size, size_t gua
10411041
}
10421042
}
10431043

1044-
static int regions_grow(void) {
1044+
static bool regions_grow(void) {
10451045
struct region_allocator *ra = ro.region_allocator;
10461046

10471047
if (ra->total > SIZE_MAX / sizeof(struct region_metadata) / 2) {
1048-
return 1;
1048+
return true;
10491049
}
10501050

10511051
size_t newtotal = ra->total * 2;
10521052
size_t newsize = newtotal * sizeof(struct region_metadata);
10531053
size_t mask = newtotal - 1;
10541054

10551055
if (newtotal > MAX_REGION_TABLE_SIZE) {
1056-
return 1;
1056+
return true;
10571057
}
10581058

10591059
struct region_metadata *p = ra->regions == ro.regions[0] ?
10601060
ro.regions[1] : ro.regions[0];
10611061

10621062
if (memory_protect_rw_metadata(p, newsize)) {
1063-
return 1;
1063+
return true;
10641064
}
10651065

10661066
for (size_t i = 0; i < ra->total; i++) {
@@ -1084,15 +1084,15 @@ static int regions_grow(void) {
10841084
ra->free = ra->free + ra->total;
10851085
ra->total = newtotal;
10861086
ra->regions = p;
1087-
return 0;
1087+
return false;
10881088
}
10891089

1090-
static int regions_insert(void *p, size_t size, size_t guard_size) {
1090+
static bool regions_insert(void *p, size_t size, size_t guard_size) {
10911091
struct region_allocator *ra = ro.region_allocator;
10921092

10931093
if (ra->free * 4 < ra->total) {
10941094
if (regions_grow()) {
1095-
return 1;
1095+
return true;
10961096
}
10971097
}
10981098

@@ -1107,7 +1107,7 @@ static int regions_insert(void *p, size_t size, size_t guard_size) {
11071107
ra->regions[index].size = size;
11081108
ra->regions[index].guard_size = guard_size;
11091109
ra->free--;
1110-
return 0;
1110+
return false;
11111111
}
11121112

11131113
static struct region_metadata *regions_find(const void *p) {

0 commit comments

Comments
 (0)