From cfd8cd94e51749182a0d0fe10846256c2e6ca6d9 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 23 Jul 2022 14:03:49 +0100 Subject: [PATCH] Hunk_Begin/Alloc attr malloc addition. --- src/common/header/shared.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/header/shared.h b/src/common/header/shared.h index 8d3b12b1..9fb97019 100644 --- a/src/common/header/shared.h +++ b/src/common/header/shared.h @@ -64,6 +64,7 @@ typedef unsigned char byte; #define YQ2_ALIGNAS_TYPE(TYPE) __attribute__(( __aligned__(__alignof__(TYPE)) )) // must be used as prefix (YQ2_ATTR_NORETURN void bla();)! #define YQ2_ATTR_NORETURN __attribute__ ((noreturn)) + #define YQ2_ATTR_MALLOC __attribute__ ((__malloc__)) #elif defined(_MSC_VER) // Note: We prefer VS2019 16.8 or newer in C11 mode (/std:c11), // then the __STDC_VERSION__ >= 201112L case above is used @@ -80,11 +81,13 @@ typedef unsigned char byte; // must be used as prefix (YQ2_ATTR_NORETURN void bla();)! #define YQ2_ATTR_NORETURN __declspec(noreturn) + #define YQ2_ATTR_MALLOC __declspec(restrict) #else #warning "Please add a case for your compiler here to align correctly" #define YQ2_ALIGNAS_SIZE(SIZE) #define YQ2_ALIGNAS_TYPE(TYPE) #define YQ2_ATTR_NORETURN + #define YQ2_ATTR_MALLOC #endif #if defined(__GNUC__) @@ -366,8 +369,8 @@ qboolean Sys_IsDir(const char *path); qboolean Sys_IsFile(const char *path); /* large block stack allocation routines */ -void *Hunk_Begin(int maxsize); -void *Hunk_Alloc(int size); +YQ2_ATTR_MALLOC void *Hunk_Begin(int maxsize); +YQ2_ATTR_MALLOC void *Hunk_Alloc(int size); void Hunk_Free(void *buf); int Hunk_End(void);