diff --git a/src/stack_allocator.c b/src/stack_allocator.c
index f89a9b355bd3f50ca0fff8e46ac5482c078cec14..aec9b91c1262fb501a6788edbd3da55d43020015 100644
--- a/src/stack_allocator.c
+++ b/src/stack_allocator.c
@@ -1,5 +1,6 @@
 #include "stack_allocator.h"
 
+MALLOC_FUNCTION
 static struct chunk * alloc_chunk(size_t size) {
     struct chunk * c = (struct chunk*)xalloc(sizeof(struct chunk) + size);
     c->data = c->top = c + 1;
diff --git a/src/stack_allocator.h b/src/stack_allocator.h
index 66f5d63cdc2e070a28f3e2eed9e1fee66c8b1a99..a60f11e8d1355a8d5bbfaf6f8a8a721742efd7ce 100644
--- a/src/stack_allocator.h
+++ b/src/stack_allocator.h
@@ -1,4 +1,5 @@
 #include "global.h"
+#include "pike_memory.h"
 
 struct stack_allocator {
     struct chunk * cur;
@@ -31,6 +32,7 @@ static INLINE void sa_alloc_enlarge(struct stack_allocator * a, size_t size) {
         stack_alloc_enlarge(a, size);
 }
 
+MALLOC_FUNCTION
 static INLINE void * sa_alloc_fast(struct stack_allocator * a, size_t size) {
     struct chunk * c = a->cur;
     void * ret = c->top;
@@ -38,6 +40,7 @@ static INLINE void * sa_alloc_fast(struct stack_allocator * a, size_t size) {
     return ret;
 }
 
+MALLOC_FUNCTION
 static INLINE void * sa_alloc(struct stack_allocator * a, size_t size) {
     sa_alloc_enlarge(a, size);
     return sa_alloc_fast(a, size);