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

annotate malloc-ish functions

Make them gcc friendly.  Note that realloc canot be __malloc__
attributed, according to the GCC manual.
This commit is contained in:
卜部昌平 2019-10-07 13:16:42 +09:00
parent 2f3b4029da
commit a220410be7
Notes: git 2019-10-09 12:12:54 +09:00
2 changed files with 18 additions and 4 deletions

View file

@ -221,9 +221,18 @@ RUBY_SYMBOL_EXPORT_BEGIN
# define RUBY_ATTR_ALLOC_SIZE(params)
#endif
void *ruby_xmalloc(size_t) RUBY_ATTR_ALLOC_SIZE((1));
void *ruby_xmalloc2(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
void *ruby_xcalloc(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
#ifdef __has_attribute
# if __has_attribute(malloc)
# define RUBY_ATTR_MALLOC __attribute__((__malloc__))
# endif
#endif
#ifndef RUBY_ATTR_MALLOC
# define RUBY_ATTR_MALLOC
#endif
void *ruby_xmalloc(size_t) RUBY_ATTR_MALLOC RUBY_ATTR_ALLOC_SIZE((1));
void *ruby_xmalloc2(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_ALLOC_SIZE((1,2));
void *ruby_xcalloc(size_t,size_t) RUBY_ATTR_MALLOC RUBY_ATTR_ALLOC_SIZE((1,2));
void *ruby_xrealloc(void*,size_t) RUBY_ATTR_ALLOC_SIZE((2));
void *ruby_xrealloc2(void*,size_t,size_t) RUBY_ATTR_ALLOC_SIZE((2,3));
void ruby_xfree(void*);

View file

@ -1639,7 +1639,12 @@ RUBY_SYMBOL_EXPORT_END
rb_wb_unprotected_newobj_of(klass, flags))
#define NEWOBJ_OF(obj,type,klass,flags) RB_NEWOBJ_OF(obj,type,klass,flags)
void *rb_aligned_malloc(size_t, size_t);
#ifdef __has_attribute
#if __has_attribute(alloc_align)
__attribute__((__alloc_align__(1)))
#endif
#endif
void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_MALLOC RUBY_ATTR_ALLOC_SIZE((2));
void rb_aligned_free(void *);
/* hash.c */