summaryrefslogtreecommitdiff
path: root/tests/test-reallocarray.c
Commit message (Collapse)AuthorAgeFilesLines
* maint: run 'make update-copyright'Simon Josefsson2023-01-011-1/+1
|
* license: fix GPLv3 texts to use a comma instead of semicolon.Bernhard Voelker2022-01-051-1/+1
| | | | | | | | | See: https://www.gnu.org/licenses/gpl-3.0.html#howto Run: $ git grep -l 'Foundation; either version 3' \ | xargs sed -i '/Foundation; either version 3/ s/n; e/n, e/' * All files using GPLv3: Adjust via the above command.
* maint: run 'make update-copyright'Paul Eggert2022-01-011-1/+1
|
* reallocarray-tests: port to weird platformsPaul Eggert2021-05-301-3/+6
| | | | | | * tests/test-reallocarray.c (main): Don’t assume that PTRDIFF_MAX / 2 + 1 <= SIZE_MAX. POSIX allows platforms where this isn’t true, though I don’t know of any examples.
* *alloc-gnu tests: Use ASSERT macro.Bruno Haible2021-05-141-9/+9
| | | | | | | | | | | | | | | * tests/test-malloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-calloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-realloc-gnu.c: Include "macros.h". (main): Use ASSERT. * tests/test-reallocarray.c: Include "macros.h". (main): Use ASSERT. * modules/malloc-gnu-tests (Files): Add tests/macros.h. * modules/calloc-gnu-tests (Files): Likewise. * modules/realloc-gnu-tests (Files): Likewise. * modules/reallocarray-tests (Files): Likewise.
* reallocarray tests: Avoid test failure on NetBSD.Bruno Haible2021-05-131-1/+2
| | | | * tests/test-reallocarray.c (main): Accept EOVERFLOW error code.
* reallocarray: don’t crash if item size is 0Paul Eggert2021-04-251-2/+7
| | | | | | | | | This problem affects only platforms where xalloc_oversized divides a number by the size arg. Fix this by defining xalloc_oversized (n, s) to work even if s == 0. * lib/malloca.h, lib/xalloc-oversized.h: Document new behavior. * lib/xalloc-oversized.h (__xalloc_oversized): Do not crash if S==0. * tests/test-reallocarray.c (main): Test for the bug.
* reallocarray: check for ptrdiff_t overflowPaul Eggert2021-04-241-16/+21
| | | | | | | | | | | | | | | | * doc/glibc-functions/reallocarray.texi (reallocarray): Mention ptrdiff_t overflow. * lib/reallocarray.c (reallocarray): Reindent as per usual GNU. * lib/stdlib.in.h (reallocarray): Allow reallocarray to be replaced. * m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Check for ptrdiff_t overflow. * m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Set up REPLACE_REALLOCARRAY. * modules/reallocarray (Files): Add malloc.m4. (configure.ac): Also test REPLACE_REALLOCARRAY. * modules/reallocarray-tests (Depends-on): Add stdint. * modules/stdlib (stdlib.h): Substitute REPLACE_REALLOCARRAY. * tests/test-reallocarray.c: Include stdint.h. (main): Check for ptrdiff_t overflow.
* malloc-gnu-tests, etc.: use volatile for clangPaul Eggert2021-04-201-1/+2
| | | | | | | | | | | | | | | In some more test locations, store the result of malloc etc. into a volatile pointer so that clang doesn’t optimize away the malloc and thus bypass the test. This fixes a malloc-gnu test failure on macOS 11.2.3 with clang 12.0.0 on ARM. * tests/test-alloca-opt.c (do_allocation): * tests/test-malloc-gnu.c (main): * tests/test-malloca.c (do_allocation): * tests/test-realloc-gnu.c (main): * tests/test-reallocarray.c (main): * tests/test-aligned-malloc.c (main): * tests/test-aligned_alloc.c (main): Store malloc etc. results into a volatile pointer.
* maint: run 'make update-copyright'Paul Eggert2020-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-12-311-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2019-01-011-1/+1
|
* maint: Run 'make update-copyright'Paul Eggert2018-01-011-1/+1
|
* all: prefer https: URLsPaul Eggert2017-09-131-1/+1
|
* reallocarray: minor fixesPaul Eggert2017-08-131-10/+12
| | | | | | | | * doc/glibc-functions/reallocarray.texi: Update version numbers. * m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Don't trust _cv_ contents. * modules/reallocarray (License): Change from GPL to LGPL. * tests/test-reallocarray.c (main): Fix ENOMEM typo. Indent properly and don't use tabs.
* reallocarray: New moduleDarshit Shah2017-08-131-0/+41
reallocarray is a new function in glibc 2.26 to safely allocate an array of memory locations with integer overflow protection. * MODULES.html.sh: Add reallocarray. * doc/glibc-functions/reallocarray.texi: Documentation for reallocarray. * lib/reallocarray.c: New file to implement module reallocarray. * lib/stdlib.in.h: Add function declarations for reallocarray. * m4/reallocarray.m4: New file. * m4/stdlib_h.m4: Declare reallocarray. * modules/reallocarray: New file. * modules/reallocarray-test: New file. * modules/stdlib: Coerce stdlib.h to export reallocarray. * tests/test-reallocarray.c: New test.