bug-gnulib
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]