* lib/backupfile.c: Include intprops.h.
(numbered_backup): Grow buffer by the usual 50%, not 100%.
This is easier to do now that we have xalloc_count_t.
* modules/backup-rename, modules/backupfile: Depend on intprops.
2021-04-06 Paul Eggert <eggert@cs.ucla.edu>
+ backupfile: less-aggressive buffer growth
+ * lib/backupfile.c: Include intprops.h.
+ (numbered_backup): Grow buffer by the usual 50%, not 100%.
+ This is easier to do now that we have xalloc_count_t.
+ * modules/backup-rename, modules/backupfile: Depend on intprops.
+
xalloc-oversized: export xalloc_count_t
* lib/xalloc-oversized.h (__xalloc_oversized, xalloc_oversized):
* lib/xmalloca.h (nmalloca):
#include "attribute.h"
#include "basename-lgpl.h"
#include "idx.h"
+#include "intprops.h"
#include "opendirat.h"
#include "renameatu.h"
#include "xalloc-oversized.h"
size_t new_buffer_size = filelen + 2 + versionlenmax + 2;
if (buffer_size < new_buffer_size)
{
- if (! xalloc_oversized (new_buffer_size, 2))
- new_buffer_size *= 2;
+ xalloc_count_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);
if (!new_buf)
{
d-ino
fcntl-h
idx
+intprops
memcmp
opendirat
readdir
d-ino
fcntl-h
idx
+intprops
memcmp
opendirat
readdir