diff options
| author | Paul Eggert | 2021-10-04 12:11:39 -0700 |
|---|---|---|
| committer | Paul Eggert | 2021-10-04 15:21:31 -0700 |
| commit | 68a256c89270ef9e97bca6097967a9ed2b050f4a (patch) | |
| tree | 7a3cca947c133bf7def967083f1054dfa4239322 /lib/malloc/dynarray-skeleton.c | |
| parent | 63cb65dccecb1146cdad7134e4b62ea3e1433880 (diff) | |
| download | emacs-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.c | 41 |
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)) |
| 196 | static void | 196 | static void |
| 197 | DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list) | 197 | DYNARRAY_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)) |
| 206 | static void | 206 | static void |
| 207 | DYNARRAY_FREE (struct DYNARRAY_STRUCT *list) | 207 | DYNARRAY_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)) |
| 217 | static inline bool | 217 | static inline bool |
| 218 | DYNARRAY_NAME (has_failed) (const struct DYNARRAY_STRUCT *list) | 218 | DYNARRAY_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)) |
| 226 | static void | 226 | static void |
| 227 | DYNARRAY_NAME (mark_failed) (struct DYNARRAY_STRUCT *list) | 227 | DYNARRAY_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)) |
| 240 | static inline size_t | 240 | static inline size_t |
| 241 | DYNARRAY_NAME (size) (const struct DYNARRAY_STRUCT *list) | 241 | DYNARRAY_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)) |
| 249 | static inline DYNARRAY_ELEMENT * | 249 | static inline DYNARRAY_ELEMENT * |
| 250 | DYNARRAY_NAME (at) (struct DYNARRAY_STRUCT *list, size_t index) | 250 | DYNARRAY_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)) |
| 261 | static inline DYNARRAY_ELEMENT * | 261 | static inline DYNARRAY_ELEMENT * |
| 262 | DYNARRAY_NAME (begin) (struct DYNARRAY_STRUCT *list) | 262 | DYNARRAY_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)) |
| 271 | static inline DYNARRAY_ELEMENT * | 271 | static inline DYNARRAY_ELEMENT * |
| 272 | DYNARRAY_NAME (end) (struct DYNARRAY_STRUCT *list) | 272 | DYNARRAY_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)) |
| 298 | static inline void | 298 | static inline void |
| 299 | DYNARRAY_NAME (add) (struct DYNARRAY_STRUCT *list, DYNARRAY_ELEMENT item) | 299 | DYNARRAY_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)) | ||
| 352 | static | 353 | static |
| 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)) |
| 376 | static bool | 377 | static bool |
| 377 | DYNARRAY_NAME (resize) (struct DYNARRAY_STRUCT *list, size_t size) | 378 | DYNARRAY_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)) |
| 421 | static void | 422 | static void |
| 422 | DYNARRAY_NAME (remove_last) (struct DYNARRAY_STRUCT *list) | 423 | DYNARRAY_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)) |
| 438 | static void | 439 | static void |
| 439 | DYNARRAY_NAME (clear) (struct DYNARRAY_STRUCT *list) | 440 | DYNARRAY_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)) | ||
| 456 | static bool | 458 | static bool |
| 457 | DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, | 459 | DYNARRAY_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)) | ||
| 487 | static DYNARRAY_ELEMENT * | 490 | static DYNARRAY_ELEMENT * |
| 488 | DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp) | 491 | DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp) |
| 489 | { | 492 | { |