#ifndef SCM___SCM_H
#define SCM___SCM_H
-/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2003, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002,2003, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
# undef SCM_ALIGNED
#endif
+/* The SCM_MALLOC macro can be used in function declarations to tell the
+ * compiler that a function may be treated as if any non-NULL pointer it returns
+ * cannot alias any other pointer valid when the function returns. */
+#if defined (__GNUC__) && (__GNUC__ >= 3)
+# define SCM_MALLOC __attribute__ ((__malloc__))
+#else
+# define SCM_MALLOC
+#endif
+
\f
/* {Supported Options}
*
SCM_API void scm_gc_mark (SCM p);
SCM_API void scm_gc_sweep (void);
-SCM_API void *scm_malloc (size_t size);
-SCM_API void *scm_calloc (size_t size);
+SCM_API void *scm_malloc (size_t size) SCM_MALLOC;
+SCM_API void *scm_calloc (size_t size) SCM_MALLOC;
SCM_API void *scm_realloc (void *mem, size_t size);
-SCM_API char *scm_strdup (const char *str);
-SCM_API char *scm_strndup (const char *str, size_t n);
+SCM_API char *scm_strdup (const char *str) SCM_MALLOC;
+SCM_API char *scm_strndup (const char *str, size_t n) SCM_MALLOC;
SCM_API void scm_gc_register_collectable_memory (void *mem, size_t size,
const char *what);
SCM_API void scm_gc_unregister_collectable_memory (void *mem, size_t size,
const char *what);
-SCM_API void *scm_gc_malloc_pointerless (size_t size, const char *what);
-SCM_API void *scm_gc_calloc (size_t size, const char *what);
-SCM_API void *scm_gc_malloc (size_t size, const char *what);
+SCM_API void *scm_gc_malloc_pointerless (size_t size, const char *what)
+ SCM_MALLOC;
+SCM_API void *scm_gc_calloc (size_t size, const char *what)
+ SCM_MALLOC;
+SCM_API void *scm_gc_malloc (size_t size, const char *what)
+ SCM_MALLOC;
SCM_API void *scm_gc_realloc (void *mem, size_t old_size,
size_t new_size, const char *what);
SCM_API void scm_gc_free (void *mem, size_t size, const char *what);
-SCM_API char *scm_gc_strdup (const char *str, const char *what);
-SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what);
+SCM_API char *scm_gc_strdup (const char *str, const char *what)
+ SCM_MALLOC;
+SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what)
+ SCM_MALLOC;
SCM_API void scm_remember_upto_here_1 (SCM obj);
SCM_API void scm_remember_upto_here_2 (SCM obj1, SCM obj2);