don't hard-code VERIFY_TAIL size

+ improve error message
This commit is contained in:
dzaima 2023-04-22 22:12:29 +03:00
parent 5395d1eb08
commit 1ff31f1df3

View File

@ -63,7 +63,10 @@ void tailVerifyAlloc(void* ptr, u64 filled, i64 logAlloc, u8 type) {
if (type==t_talloc) ((u64*)((u8*)ptr + end - 8))[0] = filled-8; // -8 because TALLOCP does a +8
}
void verifyEnd(void* ptr, u64 sz, u64 start, u64 end) {
if (end+64>sz) { printf("Bad used range: "N64u".."N64u", allocation size "N64u"\n", start, end, sz); __builtin_trap(); }
if (end+VERIFY_TAIL > sz) {
printf("Bad used range for %p: "N64u".."N64u", allocation size "N64u", usable "N64u"\n", ptr, start, end, sz, sz-VERIFY_TAIL);
__builtin_trap();
}
}
void tailVerifyReinit(void* ptr, u64 filled, u64 end) {
if(filled>end || filled<=8) { printf("Bad reinit arguments: "N64u".."N64u"\n", filled, end); __builtin_trap(); }