aboutsummaryrefslogtreecommitdiffstats
path: root/include/ruby/defines.h
diff options
context:
space:
mode:
authorkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-03 21:03:58 +0000
committerkosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-03 21:03:58 +0000
commit9b89888ddafcfd8f13f3f7535ce1744e005bac3b (patch)
treefc2fa8ebdee999995e24d77bb8bc4c0e498661b6 /include/ruby/defines.h
parentb35529bb4e9b7c1f328e4515106b4b96aec94167 (diff)
downloadruby-9b89888ddafcfd8f13f3f7535ce1744e005bac3b.tar.gz
* include/ruby/defines.h (RUBY_ATTR_ALLOC_SIZE): New for
attribute((alloc_size(params))). * include/ruby/defines.h (xmalloc, xmalloc2, xcalloc) (xrealloc, xrealloc2): Annotated by RUBY_ATTR_ALLOC_SIZE. * include/ruby/ruby.h (rb_alloc_tmp_buffer): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include/ruby/defines.h')
-rw-r--r--include/ruby/defines.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/ruby/defines.h b/include/ruby/defines.h
index f6fe2c9832..ec6a1a94d5 100644
--- a/include/ruby/defines.h
+++ b/include/ruby/defines.h
@@ -106,11 +106,17 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define xrealloc2 ruby_xrealloc2
#define xfree ruby_xfree
-void *xmalloc(size_t);
-void *xmalloc2(size_t,size_t);
-void *xcalloc(size_t,size_t);
-void *xrealloc(void*,size_t);
-void *xrealloc2(void*,size_t,size_t);
+#if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
+# define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((__alloc_size__ params))
+#else
+# define RUBY_ATTR_ALLOC_SIZE(params)
+#endif
+
+void *xmalloc(size_t) RUBY_ATTR_ALLOC_SIZE((1));
+void *xmalloc2(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
+void *xcalloc(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
+void *xrealloc(void*,size_t) RUBY_ATTR_ALLOC_SIZE((2));
+void *xrealloc2(void*,size_t,size_t) RUBY_ATTR_ALLOC_SIZE((2,3));
void xfree(void*);
#define STRINGIZE(expr) STRINGIZE0(expr)