summaryrefslogtreecommitdiff
path: root/lib/exclude.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-10-16 07:05:31 +0000
committerJim Meyering <jim@meyering.net>2003-10-16 07:05:31 +0000
commit523b7f35cd063575ad1d4494067988f7f74979db (patch)
treebe483874ef16db005074cea80814acb54f2ab57d /lib/exclude.c
parent2a557bab23930c47dea8fafd6673ed0912ecef57 (diff)
downloadcoreutils-523b7f35cd063575ad1d4494067988f7f74979db.tar.xz
Update from gnulib.
Diffstat (limited to 'lib/exclude.c')
-rw-r--r--lib/exclude.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/lib/exclude.c b/lib/exclude.c
index 3d1d3bfcb..cb4332666 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -35,23 +35,12 @@ extern int errno;
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-# include <stdint.h>
-# endif
-#endif
#include "exclude.h"
#include "fnmatch.h"
#include "unlocked-io.h"
#include "xalloc.h"
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
#if STDC_HEADERS || (! defined isascii && ! HAVE_ISASCII)
# define IN_CTYPE_DOMAIN(c) true
#else
@@ -106,7 +95,7 @@ new_exclude (void)
{
struct exclude *ex = xmalloc (sizeof *ex);
ex->exclude_count = 0;
- ex->exclude_alloc = (1 << 6); /* This must be a power of 2. */
+ ex->exclude_alloc = 60;
ex->exclude = xmalloc (ex->exclude_alloc * sizeof ex->exclude[0]);
return ex;
}
@@ -201,11 +190,9 @@ add_exclude (struct exclude *ex, char const *pattern, int options)
if (ex->exclude_alloc <= ex->exclude_count)
{
- size_t s = 2 * ex->exclude_alloc;
- if (! (0 < s && s <= SIZE_MAX / sizeof ex->exclude[0]))
- xalloc_die ();
- ex->exclude_alloc = s;
- ex->exclude = xrealloc (ex->exclude, s * sizeof ex->exclude[0]);
+ ex->exclude = xnrealloc (ex->exclude, ex->exclude_alloc,
+ 2 * sizeof *ex->exclude);
+ ex->exclude_alloc *= 2;
}
patopts = &ex->exclude[ex->exclude_count++];
@@ -229,7 +216,7 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
char *p;
char const *pattern;
char const *lim;
- size_t buf_alloc = (1 << 10); /* This must be a power of two. */
+ size_t buf_alloc = 1000;
size_t buf_count = 0;
int c;
int e = 0;
@@ -246,10 +233,8 @@ add_exclude_file (void (*add_func) (struct exclude *, char const *, int),
buf[buf_count++] = c;
if (buf_count == buf_alloc)
{
+ buf = xnrealloc (buf, buf_alloc, 2);
buf_alloc *= 2;
- if (! buf_alloc)
- xalloc_die ();
- buf = xrealloc (buf, buf_alloc);
}
}