1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

malloc-gnu: depend on stdckdint not xalloc-oversized

* lib/malloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_malloc): Use ckd_mul instead of xalloc_oversized.
* modules/malloc-gnu, modules/malloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.
This commit is contained in:
Paul Eggert
2024-11-03 12:19:33 -08:00
parent 9334b1c63b
commit 9c3ebd3bec
4 changed files with 11 additions and 5 deletions

View File

@@ -1,5 +1,11 @@
2024-11-04 Paul Eggert <eggert@cs.ucla.edu> 2024-11-04 Paul Eggert <eggert@cs.ucla.edu>
malloc-gnu: depend on stdckdint not xalloc-oversized
* lib/malloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_malloc): Use ckd_mul instead of xalloc_oversized.
* modules/malloc-gnu, modules/malloc-posix:
(Depends-on): Depend on stdckdint, not xalloc-oversized.
calloc: depend on stdckdint not xalloc-oversized calloc: depend on stdckdint not xalloc-oversized
* lib/calloc.c: Include stdckdint.h, xalloc-oversized.h. * lib/calloc.c: Include stdckdint.h, xalloc-oversized.h.
(rpl_calloc): Use ckd_mul instead of xalloc_oversized. (rpl_calloc): Use ckd_mul instead of xalloc_oversized.

View File

@@ -23,8 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdckdint.h>
#include "xalloc-oversized.h"
/* Allocate an N-byte block of memory from the heap, even if N is 0. */ /* Allocate an N-byte block of memory from the heap, even if N is 0. */
@@ -34,7 +33,8 @@ rpl_malloc (size_t n)
if (n == 0) if (n == 0)
n = 1; n = 1;
if (xalloc_oversized (n, 1)) ptrdiff_t signed_n;
if (ckd_add (&signed_n, n, 0))
{ {
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;

View File

@@ -7,7 +7,7 @@ lib/malloc.c
Depends-on: Depends-on:
malloc-posix malloc-posix
extensions-aix extensions-aix
xalloc-oversized [test $REPLACE_MALLOC_FOR_MALLOC_GNU = 1] stdckdint [test $REPLACE_CALLOC_FOR_MALLOC_GNU = 1]
configure.ac: configure.ac:
gl_FUNC_MALLOC_GNU gl_FUNC_MALLOC_GNU

View File

@@ -6,8 +6,8 @@ lib/malloc.c
m4/malloc.m4 m4/malloc.m4
Depends-on: Depends-on:
stdckdint [test $REPLACE_CALLOC_FOR_MALLOC_POSIX = 1]
stdlib stdlib
xalloc-oversized [test $REPLACE_MALLOC_FOR_MALLOC_POSIX = 1]
configure.ac: configure.ac:
AC_REQUIRE([gl_FUNC_MALLOC_POSIX]) AC_REQUIRE([gl_FUNC_MALLOC_POSIX])