Ruby 3.5.0dev (2025-02-20 revision 34098b669c0cbc024cd08e686891f1dfe0a10aaf)
xmalloc.h
Go to the documentation of this file.
1#ifndef RBIMPL_XMALLOC_H /*-*-C++-*-vi:se ft=cpp:*/
2#define RBIMPL_XMALLOC_H
23#include "ruby/internal/config.h"
24
25#ifdef STDC_HEADERS
26# include <stddef.h>
27#endif
28
29#ifdef HAVE_STDLIB_H
30# include <stdlib.h>
31#endif
32
39
49#ifndef USE_GC_MALLOC_OBJ_INFO_DETAILS
50# define USE_GC_MALLOC_OBJ_INFO_DETAILS 0
51#endif
52
53#define xmalloc ruby_xmalloc
54#define xmalloc2 ruby_xmalloc2
55#define xcalloc ruby_xcalloc
56#define xrealloc ruby_xrealloc
57#define xrealloc2 ruby_xrealloc2
58#define xfree ruby_xfree
61
86void *ruby_xmalloc(size_t size)
87RBIMPL_ATTR_NOEXCEPT(malloc(size))
88;
89
117void *ruby_xmalloc2(size_t nelems, size_t elemsiz)
118RBIMPL_ATTR_NOEXCEPT(malloc(nelems * elemsiz))
119;
120
147void *ruby_xcalloc(size_t nelems, size_t elemsiz)
148RBIMPL_ATTR_NOEXCEPT(calloc(nelems, elemsiz))
149;
150
193void *ruby_xrealloc(void *ptr, size_t newsiz)
194RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newsiz))
195;
196
250void *ruby_xrealloc2(void *ptr, size_t newelems, size_t newsiz)
251RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newelems * newsiz))
252;
253
282void ruby_xfree(void *ptr)
283RBIMPL_ATTR_NOEXCEPT(free(ptr))
284;
285
287
288#endif /* RBIMPL_XMALLOC_H */
Defines RBIMPL_ATTR_ALLOC_SIZE.
#define RBIMPL_ATTR_ALLOC_SIZE(tuple)
Wraps (or simulates) __attribute__((alloc_size))
Definition alloc_size.h:29
Tweaking visibility of C variables/functions.
#define RBIMPL_SYMBOL_EXPORT_END()
Counterpart of RBIMPL_SYMBOL_EXPORT_BEGIN.
Definition dllexport.h:74
#define RBIMPL_SYMBOL_EXPORT_BEGIN()
Shortcut macro equivalent to RUBY_SYMBOL_EXPORT_BEGIN extern "C" {.
Definition dllexport.h:65
Defines RBIMPL_ATTR_NODISCARD.
#define RBIMPL_ATTR_NODISCARD()
Wraps (or simulates) [[nodiscard]].
Definition nodiscard.h:42
Defines RBIMPL_ATTR_NOEXCEPT.
#define RBIMPL_ATTR_NOEXCEPT(_)
Wraps (or simulates) C++11 noexcept
Definition noexcept.h:85
Defines RBIMPL_ATTR_RESTRICT.
#define RBIMPL_ATTR_RESTRICT()
Wraps (or simulates) __declspec(restrict)
Definition restrict.h:41
Defines RBIMPL_ATTR_RETURNS_NONNULL.
#define RBIMPL_ATTR_RETURNS_NONNULL()
Wraps (or simulates) __attribute__((returns_nonnull))
void * ruby_xrealloc(void *ptr, size_t newsiz)
Resize the storage instance.
Definition gc.c:4751
void * ruby_xrealloc2(void *ptr, size_t newelems, size_t newsiz)
Identical to ruby_xrealloc(), except it resizes the given storage instance to newelems * newsiz bytes...
Definition gc.c:4775
void ruby_xfree(void *ptr)
Deallocates a storage instance.
Definition gc.c:4800
void * ruby_xmalloc2(size_t nelems, size_t elemsiz)
Identical to ruby_xmalloc(), except it allocates nelems * elemsiz bytes.
Definition gc.c:4704
void * ruby_xmalloc(size_t size)
Allocates a storage instance.
Definition gc.c:4670
void * ruby_xcalloc(size_t nelems, size_t elemsiz)
Identical to ruby_xmalloc2(), except it returns a zero-filled storage instance.
Definition gc.c:4718