aboutsummaryrefslogtreecommitdiff
path: root/src/gb
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-08 14:45:53 +0100
committergingerBill <bill@gingerbill.org>2021-09-08 14:45:53 +0100
commit76419383a818213ffbd72d08a53ab70716122f8b (patch)
treed79b465e471757c758c3f0cd81b9e5ba3816f426 /src/gb
parent3aa2924a065a3235ae76cf51e14859739a2d1d0d (diff)
Add some minor sanity checks to the compiler's `heap_allocator_proc` on Darwin
Diffstat (limited to 'src/gb')
-rw-r--r--src/gb/gb.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gb/gb.h b/src/gb/gb.h
index 5ee32da64..70e4d0ab0 100644
--- a/src/gb/gb.h
+++ b/src/gb/gb.h
@@ -3123,18 +3123,22 @@ gb_inline void *gb_memset(void *dest, u8 c, isize n) {
return NULL;
}
- if (n == 0)
+ if (n <= 0) {
return dest;
+ }
s[0] = s[n-1] = c;
- if (n < 3)
+ if (n < 3) {
return dest;
+ }
s[1] = s[n-2] = c;
s[2] = s[n-3] = c;
- if (n < 7)
+ if (n < 7) {
return dest;
+ }
s[3] = s[n-4] = c;
- if (n < 9)
+ if (n < 9) {
return dest;
+ }
k = -cast(intptr)s & 3;
s += k;