1 diff -Bburpd make-3.81_orig/file.c make-3.81/file.c
2 --- make-3.81_orig/file.c 2006-05-23 13:59:11.000000000 +0200
3 +++ make-3.81/file.c 2006-05-23 14:39:34.000000000 +0200
4 @@ -490,7 +490,7 @@ expand_deps (struct file *f)
6 o = subst_expand (buffer, d->name, "%", "$*", 1, 2, 0);
9 + hash_strfree (d->name);
10 d->name = savestring (buffer, o - buffer);
11 d->staticpattern = 0; /* Clear staticpattern so that we don't
12 re-expand %s below. */
13 @@ -549,7 +549,7 @@ expand_deps (struct file *f)
18 + hash_strfree (dp->name);
19 dp->name = savestring (buffer, o - buffer);
22 @@ -580,7 +580,7 @@ expand_deps (struct file *f)
24 d1->file = enter_file (d1->name);
27 + hash_strfree (d1->name);
29 d1->staticpattern = 0;
30 d1->need_2nd_expansion = 0;
31 Only in make-3.81: file.c~
32 diff -Bburpd make-3.81_orig/implicit.c make-3.81/implicit.c
33 --- make-3.81_orig/implicit.c 2006-05-23 13:59:11.000000000 +0200
34 +++ make-3.81/implicit.c 2006-05-23 14:40:01.000000000 +0200
35 @@ -864,7 +864,7 @@ pattern_search (struct file *file, int a
36 dep->file = enter_file (dep->name);
37 /* enter_file uses dep->name _if_ we created a new file. */
38 if (dep->name != dep->file->name)
40 + hash_strfree (dep->name);
42 dep->file->tried_implicit |= dep->changed;
44 Only in make-3.81: implicit.c~
45 diff -Bburpd make-3.81_orig/main.c make-3.81/main.c
46 --- make-3.81_orig/main.c 2006-05-23 13:59:11.000000000 +0200
47 +++ make-3.81/main.c 2006-05-23 14:40:49.000000000 +0200
48 @@ -540,6 +540,7 @@ initialize_global_hash_tables (void)
50 hash_init_directories ();
51 hash_init_function_table ();
52 + init_hash_strings ();
56 Only in make-3.81: main.c~
57 diff -Bburpd make-3.81_orig/make.h make-3.81/make.h
58 --- make-3.81_orig/make.h 2006-05-23 13:59:11.000000000 +0200
59 +++ make-3.81/make.h 2006-05-23 14:41:21.000000000 +0200
60 @@ -431,6 +431,11 @@ extern void print_spaces PARAMS ((unsign
61 extern char *find_percent PARAMS ((char *));
62 extern FILE *open_tmpfile PARAMS ((char **, const char *));
64 +extern void init_hash_strings PARAMS ((void));
65 +extern char *hash_strdup PARAMS ((const char *));
66 +extern char *hash_savestring PARAMS ((const char *, unsigned int));
67 +extern void hash_strfree PARAMS ((char *));
70 extern int ar_name PARAMS ((char *));
71 extern void ar_parse_name PARAMS ((char *, char **, char **));
72 Only in make-3.81: make.h~
73 diff -Bburpd make-3.81_orig/misc.c make-3.81/misc.c
74 --- make-3.81_orig/misc.c 2006-05-23 13:59:11.000000000 +0200
75 +++ make-3.81/misc.c 2006-05-23 14:42:59.000000000 +0200
76 @@ -16,8 +16,10 @@ You should have received a copy of the G
77 GNU Make; see the file COPYING. If not, write to the Free Software
78 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */
86 /* Variadic functions. We go through contortions to allow proper function
87 @@ -511,7 +513,7 @@ void
88 free_dep (struct dep *d)
92 + hash_strfree (d->name);
96 @@ -535,7 +537,7 @@ copy_dep_chain (const struct dep *d)
97 bcopy ((char *) d, (char *) c, sizeof (struct dep));
100 - c->name = xstrdup (c->name);
101 + c->name = hash_strdup (c->name);
103 c->stem = xstrdup (c->stem);
105 @@ -909,3 +911,154 @@ close_stdout (void)
110 +/* Hash table of duplicated strings. */
115 + unsigned int count;
118 +static unsigned long
122 + return_ISTRING_HASH_1 (((const struct hash_string *) key)->string);
125 +static unsigned long
129 + return_ISTRING_HASH_2 (((const struct hash_string *) key)->string);
133 +string_hash_cmp (x, y)
137 + return_ISTRING_COMPARE (((const struct hash_string *) x)->string,
138 + ((const struct hash_string *) y)->string);
141 +static struct hash_table strings;
144 +init_hash_strings ()
146 + hash_init (&strings, 1000, string_hash_1, string_hash_2,
150 +/* Keep track duplicated string and return the old one if exists. */
156 + struct hash_string *h, key;
161 + key.string = (char *) ptr;
163 + h = (struct hash_string *) hash_find_item (&strings, &key);
166 + char *result = (char *) malloc (strlen (ptr) + 1);
168 + if (result == NULL)
169 + fatal (NILF, _("virtual memory exhausted"));
171 + strcpy (result, ptr);
173 + h = (struct hash_string *) malloc (sizeof (struct hash_string));
175 + fatal (NILF, _("virtual memory exhausted"));
177 + h->string = result;
179 + hash_insert (&strings, h);
184 + assert (h->count != 0);
191 +hash_savestring (str, length)
193 + unsigned int length;
195 + struct hash_string *h, key;
197 + if (length == 0 || *str == '\0')
200 + key.string = alloca (length + 1);
202 + bcopy (str, key.string, length);
203 + key.string [length] = '\0';
205 + h = (struct hash_string *) hash_find_item (&strings, &key);
208 + char *out = (char *) xmalloc (length + 1);
209 + bcopy (str, out, length);
210 + out[length] = '\0';
212 + h = (struct hash_string *) malloc (sizeof (struct hash_string));
214 + fatal (NILF, _("virtual memory exhausted"));
218 + hash_insert (&strings, h);
223 + assert (h->count != 0);
233 + struct hash_string *h, key;
240 + h = (struct hash_string *) hash_find_item (&strings, &key);
242 + /* Check if string comes from hash_strdup or hash_savestring. */
243 + if (h == NULL || h->string != ptr)
252 + struct hash_string *d;
254 + d = hash_delete (&strings, h);
260 Only in make-3.81: misc.c~
261 Only in make-3.81: read.c~