[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/8] backupfile: simplify via realloc-gnu
From: |
Paul Eggert |
Subject: |
[PATCH 2/8] backupfile: simplify via realloc-gnu |
Date: |
Sun, 18 Apr 2021 21:01:53 -0700 |
* lib/backupfile.c: Do not include xalloc-oversized.h.
(numbered_backup): Simplify now that realloc will do the right
thing about ptrdiff_t overflow.
* modules/backupfile (Depends-on): Add realloc-gnu;
remove xalloc-oversized.
---
ChangeLog | 7 +++++++
lib/backupfile.c | 3 +--
modules/backupfile | 2 +-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d2d12058e..e00a5b7c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2021-04-18 Paul Eggert <eggert@cs.ucla.edu>
+ backupfile: simplify via realloc-gnu
+ * lib/backupfile.c: Do not include xalloc-oversized.h.
+ (numbered_backup): Simplify now that realloc will do the right
+ thing about ptrdiff_t overflow.
+ * modules/backupfile (Depends-on): Add realloc-gnu;
+ remove xalloc-oversized.
+
safe-alloc: improve doc
* doc/safe-alloc.texi: Clarify that reallocating an array appends
uninitialized storage. Say ‘sizeof *p’ rather than ‘sizeof(*p)’
diff --git a/lib/backupfile.c b/lib/backupfile.c
index 1e427e8de..bc03dd614 100644
--- a/lib/backupfile.c
+++ b/lib/backupfile.c
@@ -37,7 +37,6 @@
#include "intprops.h"
#include "opendirat.h"
#include "renameatu.h"
-#include "xalloc-oversized.h"
#ifndef _D_EXACT_NAMLEN
# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
@@ -271,7 +270,7 @@ numbered_backup (int dir_fd, char **buffer, size_t
buffer_size, size_t filelen,
size_t new_buffer_size = filelen + 2 + versionlenmax + 2;
if (buffer_size < new_buffer_size)
{
- xalloc_count_t grown;
+ size_t grown;
if (! INT_ADD_WRAPV (new_buffer_size, new_buffer_size >> 1, &grown))
new_buffer_size = grown;
char *new_buf = realloc (buf, new_buffer_size);
diff --git a/modules/backupfile b/modules/backupfile
index 42c8c9ed5..342a7bdff 100644
--- a/modules/backupfile
+++ b/modules/backupfile
@@ -21,11 +21,11 @@ intprops
memcmp
opendirat
readdir
+realloc-gnu
renameatu
stdbool
stdint
xalloc-die
-xalloc-oversized
configure.ac:
gl_BACKUPFILE
--
2.27.0
- [PATCH 1/8] safe-alloc: improve doc, Paul Eggert, 2021/04/19
- [PATCH 2/8] backupfile: simplify via realloc-gnu,
Paul Eggert <=
- [PATCH 3/8] group-member: simplify via realloc-gnu, Paul Eggert, 2021/04/19
- [PATCH 4/8] xalloc: new function xreallocarray, Paul Eggert, 2021/04/19
- [PATCH 6/8] safe-alloc: simplify via reallocarray, Paul Eggert, 2021/04/19
- [PATCH 7/8] calloc-gnu: now LGPLv2+, Paul Eggert, 2021/04/19
- [PATCH 8/8] safe-alloc: fix pointer implementation, Paul Eggert, 2021/04/19
- [PATCH 5/8] xalloc-oversized: fix SIZE_MAX optimization bug, Paul Eggert, 2021/04/19
- Re: [PATCH 1/8] safe-alloc: improve doc, Eric Blake, 2021/04/22