@@ -61,21 +61,23 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
61
61
62
62
RBIMPL_ATTR_NODISCARD()
63
63
RBIMPL_ATTR_RESTRICT()
64
- RBIMPL_ATTR_RETURNS_NONNULL()
65
64
RBIMPL_ATTR_ALLOC_SIZE((1 ))
66
65
/* *
67
- * Allocates a storage instance. It is largely the same as system malloc(),
68
- * except:
66
+ * Allocates a storage instance. It is largely the same as system malloc().
67
+ * Especially when called from outside of GVL this is identical to it, at least
68
+ * API-wise. But when under GVL, it exercises some additional manoeuvre
69
+ * namely:
69
70
*
70
71
* - It raises Ruby exceptions instead of returning NULL, and
71
72
* - In case of `ENOMEM` it tries to GC to make some room.
72
73
*
73
74
* @param[in] size Requested amount of memory.
74
75
* @exception rb_eNoMemError No space left for `size` bytes allocation.
75
- * @return A valid pointer to an allocated storage instance; which has at
76
- * least `size` bytes width, with appropriate alignment detected by
77
- * the underlying malloc() routine.
78
- * @note It doesn't return NULL.
76
+ * @retval NULL Allocation failed but no way to raise anything.
77
+ * @retval otherwise A valid pointer to an allocated storage
78
+ * instance; which has at least `size` bytes width,
79
+ * with appropriate alignment detected by the
80
+ * underlying malloc() routine.
79
81
* @note Unlike some malloc() implementations, it allocates something and
80
82
* returns a meaningful value even when `size` is equal to zero.
81
83
* @warning The return value shall be invalidated exactly once by either
@@ -89,7 +91,6 @@ RBIMPL_ATTR_NOEXCEPT(malloc(size))
89
91
90
92
RBIMPL_ATTR_NODISCARD ()
91
93
RBIMPL_ATTR_RESTRICT()
92
- RBIMPL_ATTR_RETURNS_NONNULL()
93
94
RBIMPL_ATTR_ALLOC_SIZE((1 ,2 ))
94
95
/* *
95
96
* Identical to ruby_xmalloc(), except it allocates `nelems` * `elemsiz` bytes.
@@ -102,10 +103,12 @@ RBIMPL_ATTR_ALLOC_SIZE((1,2))
102
103
* @param[in] elemsiz Size of an element.
103
104
* @exception rb_eNoMemError No space left for allocation.
104
105
* @exception rb_eArgError `nelems` * `elemsiz` would overflow.
105
- * @return A valid pointer to an allocated storage instance; which has at
106
- * least `nelems` * `elemsiz` bytes width, with appropriate
107
- * alignment detected by the underlying malloc() routine.
108
- * @note It doesn't return NULL.
106
+ * @retval NULL Allocation failed but no way to raise anything.
107
+ * @retval otherwise A valid pointer to an allocated storage
108
+ * instance; which has at least `nelems` *
109
+ * `elemsiz` bytes width, with appropriate
110
+ * alignment detected by the underlying malloc()
111
+ * routine.
109
112
* @note Unlike some malloc() implementations, it allocates something and
110
113
* returns a meaningful value even when `nelems` or `elemsiz` or
111
114
* both are zero.
@@ -120,7 +123,6 @@ RBIMPL_ATTR_NOEXCEPT(malloc(nelems * elemsiz))
120
123
121
124
RBIMPL_ATTR_NODISCARD ()
122
125
RBIMPL_ATTR_RESTRICT()
123
- RBIMPL_ATTR_RETURNS_NONNULL()
124
126
RBIMPL_ATTR_ALLOC_SIZE((1 ,2 ))
125
127
/* *
126
128
* Identical to ruby_xmalloc2(), except it returns a zero-filled storage
@@ -131,11 +133,13 @@ RBIMPL_ATTR_ALLOC_SIZE((1,2))
131
133
* @param[in] elemsiz Size of an element.
132
134
* @exception rb_eNoMemError No space left for allocation.
133
135
* @exception rb_eArgError `nelems` * `elemsiz` would overflow.
134
- * @return A valid pointer to an allocated storage instance; which has at
135
- * least `nelems` * `elemsiz` bytes width, with appropriate
136
- * alignment detected by the underlying calloc() routine.
136
+ * @retval NULL Allocation failed but no way to raise anything.
137
+ * @retval otherwise A valid pointer to an allocated storage
138
+ * instance; which has at least `nelems` *
139
+ * `elemsiz` bytes width, with appropriate
140
+ * alignment detected by the underlying calloc()
141
+ * routine.
137
142
* @post The returned storage instance is filled with zeros.
138
- * @note It doesn't return NULL.
139
143
* @note Unlike some calloc() implementations, it allocates something and
140
144
* returns a meaningful value even when `nelems` or `elemsiz` or
141
145
* both are zero.
@@ -149,7 +153,6 @@ RBIMPL_ATTR_NOEXCEPT(calloc(nelems, elemsiz))
149
153
;
150
154
151
155
RBIMPL_ATTR_NODISCARD ()
152
- RBIMPL_ATTR_RETURNS_NONNULL()
153
156
RBIMPL_ATTR_ALLOC_SIZE((2 ))
154
157
/* *
155
158
* Resize the storage instance.
@@ -163,10 +166,11 @@ RBIMPL_ATTR_ALLOC_SIZE((2))
163
166
* - ruby_xrealloc2().
164
167
* @param[in] newsiz Requested new amount of memory.
165
168
* @exception rb_eNoMemError No space left for `newsiz` bytes allocation.
166
- * @return A valid pointer to a (possibly newly allocated) storage
167
- * instance; which has at least `newsiz` bytes width, with
168
- * appropriate alignment detected by the underlying realloc()
169
- * routine.
169
+ * @retval NULL Allocation failed but no way to raise anything.
170
+ * @retval otherwise A valid pointer to a (possibly newly allocated)
171
+ * storage instance; which has at least `newsiz`
172
+ * bytes width, with appropriate alignment detected
173
+ * by the underlying realloc() routine.
170
174
* @pre The passed pointer must point to a valid live storage instance.
171
175
* It is a failure to pass an already freed pointer.
172
176
* @post In case the function returns the passed pointer as-is, the
@@ -175,7 +179,6 @@ RBIMPL_ATTR_ALLOC_SIZE((2))
175
179
* pointer to a newly allocated storage instance is returned. In
176
180
* this case `ptr` is invalidated as if it was passed to
177
181
* ruby_xfree().
178
- * @note It doesn't return NULL.
179
182
* @warning Unlike some realloc() implementations, passing zero to `newsiz`
180
183
* is not the same as calling ruby_xfree(), because this function
181
184
* never returns NULL. Something meaningful still returns then.
@@ -195,7 +198,6 @@ RBIMPL_ATTR_NOEXCEPT(realloc(ptr, newsiz))
195
198
;
196
199
197
200
RBIMPL_ATTR_NODISCARD ()
198
- RBIMPL_ATTR_RETURNS_NONNULL()
199
201
RBIMPL_ATTR_ALLOC_SIZE((2 ,3 ))
200
202
/* *
201
203
* Identical to ruby_xrealloc(), except it resizes the given storage instance
@@ -219,10 +221,12 @@ RBIMPL_ATTR_ALLOC_SIZE((2,3))
219
221
* @param[in] newsiz Requested new size of each element.
220
222
* @exception rb_eNoMemError No space left for allocation.
221
223
* @exception rb_eArgError `newelems` * `newsiz` would overflow.
222
- * @return A valid pointer to a (possibly newly allocated) storage
223
- * instance; which has at least `newelems` * `newsiz` bytes width,
224
- * with appropriate alignment detected by the underlying realloc()
225
- * routine.
224
+ * @retval NULL Allocation failed but no way to raise anything.
225
+ * @retval otherwise A valid pointer to a (possibly newly allocated)
226
+ * storage instance; which has at least `newelems`
227
+ * * `newsiz` bytes width, with appropriate
228
+ * alignment detected by the underlying realloc()
229
+ * routine.
226
230
* @pre The passed pointer must point to a valid live storage instance.
227
231
* It is a failure to pass an already freed pointer.
228
232
* @post In case the function returns the passed pointer as-is, the
@@ -231,7 +235,6 @@ RBIMPL_ATTR_ALLOC_SIZE((2,3))
231
235
* Otherwise a valid pointer to a newly allocated storage instance
232
236
* is returned. In this case `ptr` is invalidated as if it was
233
237
* passed to ruby_xfree().
234
- * @note It doesn't return NULL.
235
238
* @warning Unlike some realloc() implementations, passing zero to either
236
239
* `newelems` or `elemsiz` are not the same as calling
237
240
* ruby_xfree(), because this function never returns NULL.
0 commit comments