From b30d8f984cd2744d06044c28b6a76399e3634e00 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 30 Oct 2022 18:44:35 -0400 Subject: Add malloc attributes to allocating functions These inform the compiler that the returned value doesn't alias with anything. Also somewhat handy as pseudo-documentation. --- include/pugl/pugl.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include/pugl') diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h index 431efab..b928c9e 100644 --- a/include/pugl/pugl.h +++ b/include/pugl/pugl.h @@ -35,14 +35,20 @@ #if defined(__GNUC__) # define PUGL_CONST_FUNC __attribute__((const)) +# define PUGL_MALLOC_FUNC __attribute__((malloc)) #else # define PUGL_CONST_FUNC +# define PUGL_MALLOC_FUNC #endif #define PUGL_CONST_API \ PUGL_API \ PUGL_CONST_FUNC +#define PUGL_MALLOC_API \ + PUGL_API \ + PUGL_MALLOC_FUNC + #ifdef __cplusplus # define PUGL_BEGIN_DECLS extern "C" { # define PUGL_END_DECLS } @@ -703,7 +709,7 @@ typedef uint32_t PuglWorldFlags; @param flags Flags to control world features. @return A new world, which must be later freed with puglFreeWorld(). */ -PUGL_API +PUGL_MALLOC_API PuglWorld* puglNewWorld(PuglWorldType type, PuglWorldFlags flags); @@ -927,7 +933,7 @@ typedef PuglStatus (*PuglEventFunc)(PuglView* view, const PuglEvent* event); It must first be configured, then the system view can be created with puglRealize(). */ -PUGL_API +PUGL_MALLOC_API PuglView* puglNewView(PuglWorld* world); -- cgit v1.2.1