[前][次][番号順一覧][スレッド一覧]

ruby-changes:28520

From: kosaki <ko1@a...>
Date: Sat, 4 May 2013 06:04:09 +0900 (JST)
Subject: [ruby-changes:28520] kosaki:r40572 (trunk): * include/ruby/defines.h (RUBY_ATTR_ALLOC_SIZE): New for

kosaki	2013-05-04 06:03:58 +0900 (Sat, 04 May 2013)

  New Revision: 40572

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40572

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/defines.h
    trunk/include/ruby/ruby.h

Index: include/ruby/defines.h
===================================================================
--- include/ruby/defines.h	(revision 40571)
+++ include/ruby/defines.h	(revision 40572)
@@ -106,11 +106,17 @@ RUBY_SYMBOL_EXPORT_BEGIN https://github.com/ruby/ruby/blob/trunk/include/ruby/defines.h#L106
 #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)
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 40571)
+++ include/ruby/ruby.h	(revision 40572)
@@ -1210,7 +1210,7 @@ rb_num2char_inline(VALUE x) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1210
 
 #define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n)))
 
-void *rb_alloc_tmp_buffer(volatile VALUE *store, long len);
+void *rb_alloc_tmp_buffer(volatile VALUE *store, long len) RUBY_ATTR_ALLOC_SIZE((2));
 void rb_free_tmp_buffer(volatile VALUE *store);
 /* allocates _n_ bytes temporary buffer and stores VALUE including it
  * in _v_.  _n_ may be evaluated twice. */
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40571)
+++ ChangeLog	(revision 40572)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May  4 04:13:27 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* 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.
+
 Fri May  3 19:32:13 2013  Takeyuki FUJIOKA  <xibbar@r...>
 
 	* lib/cgi/util.rb: All class methods moduleized.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]