aboutsummaryrefslogtreecommitdiffstats
path: root/lib/malloc/dynarray-skeleton.c
diff options
context:
space:
mode:
authorPaul Eggert2021-10-04 12:11:39 -0700
committerPaul Eggert2021-10-04 15:21:31 -0700
commit68a256c89270ef9e97bca6097967a9ed2b050f4a (patch)
tree7a3cca947c133bf7def967083f1054dfa4239322 /lib/malloc/dynarray-skeleton.c
parent63cb65dccecb1146cdad7134e4b62ea3e1433880 (diff)
downloademacs-68a256c89270ef9e97bca6097967a9ed2b050f4a.tar.gz
emacs-68a256c89270ef9e97bca6097967a9ed2b050f4a.zip
Update from Gnulib
Make the following changes by hand, and run 'admin/merge-gnulib'. * .gitignore: Add lib/malloc/*.gl.h. * admin/merge-gnulib: Copy lib/af_alg.h and lib/save-cwd.h directly from Gnulib, without worrying about Gnulib modules, as these files are special cases. (AVOIDED_MODULES): Remove malloc-posix. * lib/malloc.c, lib/realloc.c, m4/malloc.m4, m4/realloc.m4: * m4/year2038.m4: New files, copied from Gnulib. * lib/malloca.c, lib/malloca.h: * m4/close-stream.m4, m4/glibc21.m4, m4/malloca.m4: Remove. These are either no longer present in Gnulib, or are no longer needed by modules that Emacs uses. * oldXMenu/AddPane.c, oldXmenu/Addsel.c: Include XmenuInt.h first; needed for new Gnulib. * src/xmenu.c: Call emacs_abort, not abort.
Diffstat (limited to 'lib/malloc/dynarray-skeleton.c')
-rw-r--r--lib/malloc/dynarray-skeleton.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/lib/malloc/dynarray-skeleton.c b/lib/malloc/dynarray-skeleton.c
index 4995fd1c049..48210e32527 100644
--- a/lib/malloc/dynarray-skeleton.c
+++ b/lib/malloc/dynarray-skeleton.c
@@ -3,16 +3,16 @@
3 This file is part of the GNU C Library. 3 This file is part of the GNU C Library.
4 4
5 The GNU C Library is free software; you can redistribute it and/or 5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public 6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 3 of the License, or (at your option) any later version. 8 version 2.1 of the License, or (at your option) any later version.
9 9
10 The GNU C Library is distributed in the hope that it will be useful, 10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Lesser General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public 15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see 16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */ 17 <https://www.gnu.org/licenses/>. */
18 18
@@ -192,7 +192,7 @@ DYNARRAY_NAME (free__array__) (struct DYNARRAY_STRUCT *list)
192 192
193/* Initialize a dynamic array object. This must be called before any 193/* Initialize a dynamic array object. This must be called before any
194 use of the object. */ 194 use of the object. */
195__nonnull ((1)) 195__attribute_nonnull__ ((1))
196static void 196static void
197DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list) 197DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
198{ 198{
@@ -202,7 +202,7 @@ DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
202} 202}
203 203
204/* Deallocate the dynamic array and its elements. */ 204/* Deallocate the dynamic array and its elements. */
205__attribute_maybe_unused__ __nonnull ((1)) 205__attribute_maybe_unused__ __attribute_nonnull__ ((1))
206static void 206static void
207DYNARRAY_FREE (struct DYNARRAY_STRUCT *list) 207DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
208{ 208{
@@ -213,7 +213,7 @@ DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
213} 213}
214 214
215/* Return true if the dynamic array is in an error state. */ 215/* Return true if the dynamic array is in an error state. */
216__nonnull ((1)) 216__attribute_nonnull__ ((1))
217static inline bool 217static inline bool
218DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list) 218DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
219{ 219{
@@ -222,7 +222,7 @@ DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list)
222 222
223/* Mark the dynamic array as failed. All elements are deallocated as 223/* Mark the dynamic array as failed. All elements are deallocated as
224 a side effect. */ 224 a side effect. */
225__nonnull ((1)) 225__attribute_nonnull__ ((1))
226static void 226static void
227DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list) 227DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
228{ 228{
@@ -236,7 +236,7 @@ DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list)
236 236
237/* Return the number of elements which have been added to the dynamic 237/* Return the number of elements which have been added to the dynamic
238 array. */ 238 array. */
239__nonnull ((1)) 239__attribute_nonnull__ ((1))
240static inline size_t 240static inline size_t
241DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list) 241DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
242{ 242{
@@ -245,7 +245,7 @@ DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list)
245 245
246/* Return a pointer to the array element at INDEX. Terminate the 246/* Return a pointer to the array element at INDEX. Terminate the
247 process if INDEX is out of bounds. */ 247 process if INDEX is out of bounds. */
248__nonnull ((1)) 248__attribute_nonnull__ ((1))
249static inline DYNARRAY_ELEMENT * 249static inline DYNARRAY_ELEMENT *
250DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index) 250DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
251{ 251{
@@ -257,7 +257,7 @@ DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index)
257/* Return a pointer to the first array element, if any. For a 257/* Return a pointer to the first array element, if any. For a
258 zero-length array, the pointer can be NULL even though the dynamic 258 zero-length array, the pointer can be NULL even though the dynamic
259 array has not entered the failure state. */ 259 array has not entered the failure state. */
260__nonnull ((1)) 260__attribute_nonnull__ ((1))
261static inline DYNARRAY_ELEMENT * 261static inline DYNARRAY_ELEMENT *
262DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list) 262DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
263{ 263{
@@ -267,7 +267,7 @@ DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list)
267/* Return a pointer one element past the last array element. For a 267/* Return a pointer one element past the last array element. For a
268 zero-length array, the pointer can be NULL even though the dynamic 268 zero-length array, the pointer can be NULL even though the dynamic
269 array has not entered the failure state. */ 269 array has not entered the failure state. */
270__nonnull ((1)) 270__attribute_nonnull__ ((1))
271static inline DYNARRAY_ELEMENT * 271static inline DYNARRAY_ELEMENT *
272DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list) 272DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list)
273{ 273{
@@ -294,7 +294,7 @@ DYNARRAY_NAME (add__) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
294/* Add ITEM at the end of the array, enlarging it by one element. 294/* Add ITEM at the end of the array, enlarging it by one element.
295 Mark *LIST as failed if the dynamic array allocation size cannot be 295 Mark *LIST as failed if the dynamic array allocation size cannot be
296 increased. */ 296 increased. */
297__nonnull ((1)) 297__attribute_nonnull__ ((1))
298static inline void 298static inline void
299DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) 299DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item)
300{ 300{
@@ -348,7 +348,8 @@ DYNARRAY_NAME (emplace__) (struct DYNARRAY_STRUCT *list)
348/* Allocate a place for a new element in *LIST and return a pointer to 348/* Allocate a place for a new element in *LIST and return a pointer to
349 it. The pointer can be NULL if the dynamic array cannot be 349 it. The pointer can be NULL if the dynamic array cannot be
350 enlarged due to a memory allocation failure. */ 350 enlarged due to a memory allocation failure. */
351__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1)) 351__attribute_maybe_unused__ __attribute_warn_unused_result__
352__attribute_nonnull__ ((1))
352static 353static
353/* Avoid inlining with the larger initialization code. */ 354/* Avoid inlining with the larger initialization code. */
354#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE)) 355#if !(defined (DYNARRAY_ELEMENT_INIT) || defined (DYNARRAY_ELEMENT_FREE))
@@ -372,7 +373,7 @@ DYNARRAY_NAME (emplace) (struct DYNARRAY_STRUCT *list)
372 existing size, new elements are added (which can be initialized). 373 existing size, new elements are added (which can be initialized).
373 Otherwise, the list is truncated, and elements are freed. Return 374 Otherwise, the list is truncated, and elements are freed. Return
374 false on memory allocation failure (and mark *LIST as failed). */ 375 false on memory allocation failure (and mark *LIST as failed). */
375__attribute_maybe_unused__ __nonnull ((1)) 376__attribute_maybe_unused__ __attribute_nonnull__ ((1))
376static bool 377static bool
377DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size) 378DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
378{ 379{
@@ -417,7 +418,7 @@ DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size)
417} 418}
418 419
419/* Remove the last element of LIST if it is present. */ 420/* Remove the last element of LIST if it is present. */
420__attribute_maybe_unused__ __nonnull ((1)) 421__attribute_maybe_unused__ __attribute_nonnull__ ((1))
421static void 422static void
422DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list) 423DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
423{ 424{
@@ -434,7 +435,7 @@ DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list)
434 435
435/* Remove all elements from the list. The elements are freed, but the 436/* Remove all elements from the list. The elements are freed, but the
436 list itself is not. */ 437 list itself is not. */
437__attribute_maybe_unused__ __nonnull ((1)) 438__attribute_maybe_unused__ __attribute_nonnull__ ((1))
438static void 439static void
439DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list) 440DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
440{ 441{
@@ -452,7 +453,8 @@ DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list)
452 stored in *RESULT if LIST refers to an empty list. On success, the 453 stored in *RESULT if LIST refers to an empty list. On success, the
453 pointer in *RESULT is heap-allocated and must be deallocated using 454 pointer in *RESULT is heap-allocated and must be deallocated using
454 free. */ 455 free. */
455__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1, 2)) 456__attribute_maybe_unused__ __attribute_warn_unused_result__
457__attribute_nonnull__ ((1, 2))
456static bool 458static bool
457DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, 459DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
458 DYNARRAY_FINAL_TYPE *result) 460 DYNARRAY_FINAL_TYPE *result)
@@ -483,7 +485,8 @@ DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
483 have a sentinel at the end). If LENGTHP is not NULL, the array 485 have a sentinel at the end). If LENGTHP is not NULL, the array
484 length is written to *LENGTHP. *LIST is re-initialized and can be 486 length is written to *LENGTHP. *LIST is re-initialized and can be
485 reused. */ 487 reused. */
486__attribute_maybe_unused__ __attribute_warn_unused_result__ __nonnull ((1)) 488__attribute_maybe_unused__ __attribute_warn_unused_result__
489__attribute_nonnull__ ((1))
487static DYNARRAY_ELEMENT * 490static DYNARRAY_ELEMENT *
488DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp) 491DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
489{ 492{