summaryrefslogtreecommitdiff
path: root/implicit.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-07-09 19:14:40 -0400
committerPaul Smith <psmith@gnu.org>2013-07-09 19:14:40 -0400
commit5601726151b3856ad26433d632392904ec059368 (patch)
tree04b9fed5f0a9ccb21cf139e3cd390ce49729e7a7 /implicit.c
parent9453a7451d66ee1ea5762a75161bf8a818c01a1f (diff)
downloadgunmake-5601726151b3856ad26433d632392904ec059368.tar.gz
Keep a local count of the max dependency list size.
This global variable could be modified during recursion so keep our own local copy to compare against.
Diffstat (limited to 'implicit.c')
-rw-r--r--implicit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/implicit.c b/implicit.c
index 97233a6..6d2e09b 100644
--- a/implicit.c
+++ b/implicit.c
@@ -217,8 +217,8 @@ pattern_search (struct file *file, int archive,
struct file *int_file = 0;
/* List of dependencies found recursively. */
- struct patdeps *deplist
- = xmalloc (max_pattern_deps * sizeof (struct patdeps));
+ unsigned int max_deps = max_pattern_deps;
+ struct patdeps *deplist = xmalloc (max_deps * sizeof (struct patdeps));
struct patdeps *pat = deplist;
/* Names of possible dependencies are constructed in this buffer. */
@@ -651,13 +651,15 @@ pattern_search (struct file *file, int archive,
/* If there are more than max_pattern_deps prerequisites (due to
2nd expansion), reset it and realloc the arrays. */
- if (deps_found > max_pattern_deps)
+ if (deps_found > max_deps)
{
unsigned int l = pat - deplist;
+ /* This might have changed due to recursion. */
+ max_pattern_deps = MAX(max_pattern_deps, deps_found);
+ max_deps = max_pattern_deps;
deplist = xrealloc (deplist,
- deps_found * sizeof (struct patdeps));
+ max_deps * sizeof (struct patdeps));
pat = deplist + l;
- max_pattern_deps = deps_found;
}
/* Go through the nameseq and handle each as a prereq name. */
@@ -757,8 +759,8 @@ pattern_search (struct file *file, int archive,
pat->pattern = int_file->name;
int_file->name = d->name;
pat->file = int_file;
- (pat++)->name = d->name;
int_file = 0;
+ (pat++)->name = d->name;
continue;
}