diff --git a/src/gd.h b/src/gd.h index 89bca20..a1e1393 100644 --- a/src/gd.h +++ b/src/gd.h @@ -65,6 +65,7 @@ extern "C" { # endif # define BGD_STDCALL __stdcall # define BGD_EXPORT_DATA_IMPL +# define BGD_MALLOC #else # if defined(__GNUC__) || defined(__clang__) # define BGD_EXPORT_DATA_PROT __attribute__ ((__visibility__ ("default"))) @@ -74,6 +75,7 @@ extern "C" { # define BGD_EXPORT_DATA_IMPL # endif # define BGD_STDCALL +# define BGD_MALLOC __attribute__ ((__malloc__)) #endif #define BGD_DECLARE(rt) BGD_EXPORT_DATA_PROT rt BGD_STDCALL diff --git a/src/gdhelpers.h b/src/gdhelpers.h index 687e156..9b187af 100644 --- a/src/gdhelpers.h +++ b/src/gdhelpers.h @@ -20,8 +20,8 @@ extern "C" { in gd.h, where callers can utilize it to correctly free memory allocated by these functions with the right version of free(). */ - void *gdCalloc (size_t nmemb, size_t size); - void *gdMalloc (size_t size); + void *gdCalloc(size_t nmemb, size_t size) BGD_MALLOC; + void *gdMalloc(size_t size) BGD_MALLOC; void *gdRealloc (void *ptr, size_t size); /* The extended version of gdReallocEx will free *ptr if the * realloc fails */