mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Use GCC's `malloc' attribute for malloc-like routines.
* libguile/__scm.h (SCM_MALLOC): New macro. * libguile/gc.h (scm_malloc, scm_calloc, scm_strdup, scm_strndup, scm_gc_malloc_pointerless, scm_gc_calloc, scm_gc_malloc, scm_gc_strdup, scm_gc_strndup): Mark as `SCM_MALLOC'.
This commit is contained in:
parent
18dcd80e37
commit
e3401c659e
2 changed files with 24 additions and 10 deletions
|
@ -3,7 +3,7 @@
|
|||
#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
|
||||
|
@ -126,6 +126,15 @@
|
|||
# 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
|
||||
|
||||
|
||||
/* {Supported Options}
|
||||
*
|
||||
|
|
|
@ -182,23 +182,28 @@ SCM_API void scm_i_gc (const char *what);
|
|||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue