diff options
| author | Jean Boussier <jean.boussier@gmail.com> | 2026-01-28 13:39:33 +0100 |
|---|---|---|
| committer | Jean Boussier <jean.boussier@gmail.com> | 2026-01-29 23:32:04 +0100 |
| commit | 91619f0230c0e5a95c796c1bd4f784c151e15614 (patch) | |
| tree | b8cf37fc6092a51f318996f382ab9503ba390100 /internal | |
| parent | 457bb11aa5b2ce4424b611acb489686d130261de (diff) | |
gc.c: Verify provided size in `rb_gc_impl_free`
For now the provided size is just for GC statistics, but in the future
we may want to forward it to C23's `free_sized` and passing an incorrect
size to it is undefined behavior.
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/gc.h | 32 | ||||
| -rw-r--r-- | internal/imemo.h | 2 |
2 files changed, 1 insertions, 33 deletions
diff --git a/internal/gc.h b/internal/gc.h index ee1f390e10..427b2f4553 100644 --- a/internal/gc.h +++ b/internal/gc.h @@ -292,36 +292,6 @@ void rb_gc_writebarrier_remember(VALUE obj); const char *rb_obj_info(VALUE obj); void ruby_annotate_mmap(const void *addr, unsigned long size, const char *name); -#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32) - -static inline void * -ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) -{ - return ruby_xrealloc(ptr, new_size); -} - -static inline void * -ruby_sized_xrealloc2_inlined(void *ptr, size_t new_count, size_t elemsiz, size_t old_count) -{ - return ruby_xrealloc2(ptr, new_count, elemsiz); -} - -static inline void -ruby_sized_xfree_inlined(void *ptr, size_t size) -{ - ruby_xfree(ptr); -} - -# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z) - -static inline void * -ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count) -{ - return ruby_xrealloc2(ptr, new_count, element_size); -} - -#else - static inline void * ruby_sized_xrealloc_inlined(void *ptr, size_t new_size, size_t old_size) { @@ -349,8 +319,6 @@ ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t ol return ruby_sized_xrealloc2(ptr, new_count, element_size, old_count); } -#endif /* HAVE_MALLOC_USABLE_SIZE */ - #define ruby_sized_xrealloc ruby_sized_xrealloc_inlined #define ruby_sized_xrealloc2 ruby_sized_xrealloc2_inlined #define ruby_sized_xfree ruby_sized_xfree_inlined diff --git a/internal/imemo.h b/internal/imemo.h index 31cc0be35a..6534cec5d7 100644 --- a/internal/imemo.h +++ b/internal/imemo.h @@ -94,7 +94,7 @@ struct vm_ifunc { struct rb_imemo_tmpbuf_struct { VALUE flags; VALUE *ptr; /* malloc'ed buffer */ - size_t cnt; /* buffer size in VALUE */ + size_t size; /* buffer size in bytes */ }; /*! MEMO |
