From 83da606072ce272eb053d4e1497d77e647cfecae Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 3 Aug 2024 23:40:31 +0100 Subject: Revise syntax macros and add a ton of branch hints My new programming style is branch hints. All non-confusing branches must be hinted when I can be bothered. It's faster, sometimes, maybe. Also, start trying to use more signed sizes in at least some of the places where it makes sense. Unsigned sizes are surprisingly error-prone! --- src/extmalloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/extmalloc.c') diff --git a/src/extmalloc.c b/src/extmalloc.c index a23dc2a..d80ab8d 100644 --- a/src/extmalloc.c +++ b/src/extmalloc.c @@ -1,5 +1,5 @@ /* - * Copyright © 2023 Michael Smith + * Copyright © 2024 Michael Smith * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -41,6 +41,8 @@ void extfree(void *mem) { Free(g_pMemAlloc, mem); } #else +#include "langext.h" + void Error(const char *fmt, ...); // stub left out of con_.h (not that useful) // Linux Source doesn't seem to bother with the custom allocator stuff at all. @@ -48,15 +50,16 @@ void Error(const char *fmt, ...); // stub left out of con_.h (not that useful) // right, not a privilege. Like func_vehicle. void *extmalloc(usize sz) { void *ret = malloc(sz); - if (!ret) Error("sst: out of memory"); + if_cold (!ret) Error("sst: out of memory"); return ret; } void *extrealloc(void *mem, usize sz) { void *ret = realloc(mem, sz); - if (!ret) Error("sst: out of memory"); + if_cold (!ret) Error("sst: out of memory"); return ret; } // note: extfree is #defined to free in the header + #endif // vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3