1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
kosaki 2013-05-03 21:03:58 +00:00
parent b35529bb4e
commit 9b89888dda
3 changed files with 21 additions and 6 deletions

View file

@ -1,3 +1,12 @@
Sat May 4 04:13:27 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* 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@ruby-lang.org> Fri May 3 19:32:13 2013 Takeyuki FUJIOKA <xibbar@ruby-lang.org>
* lib/cgi/util.rb: All class methods moduleized. * lib/cgi/util.rb: All class methods moduleized.

View file

@ -106,11 +106,17 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define xrealloc2 ruby_xrealloc2 #define xrealloc2 ruby_xrealloc2
#define xfree ruby_xfree #define xfree ruby_xfree
void *xmalloc(size_t); #if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
void *xmalloc2(size_t,size_t); # define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((__alloc_size__ params))
void *xcalloc(size_t,size_t); #else
void *xrealloc(void*,size_t); # define RUBY_ATTR_ALLOC_SIZE(params)
void *xrealloc2(void*,size_t,size_t); #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*); void xfree(void*);
#define STRINGIZE(expr) STRINGIZE0(expr) #define STRINGIZE(expr) STRINGIZE0(expr)

View file

@ -1210,7 +1210,7 @@ rb_num2char_inline(VALUE x)
#define ALLOCA_N(type,n) ((type*)alloca(sizeof(type)*(n))) #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); void rb_free_tmp_buffer(volatile VALUE *store);
/* allocates _n_ bytes temporary buffer and stores VALUE including it /* allocates _n_ bytes temporary buffer and stores VALUE including it
* in _v_. _n_ may be evaluated twice. */ * in _v_. _n_ may be evaluated twice. */