Add some minor sanity checks to the compiler's heap_allocator_proc on Darwin

This commit is contained in:
gingerBill
2021-09-08 14:45:53 +01:00
parent 3aa2924a06
commit 76419383a8
2 changed files with 23 additions and 12 deletions
+8 -4
View File
@@ -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;