aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorGeoffrey Keating <geoffk@apple.com>2004-05-30 00:49:06 +0000
committerGeoffrey Keating <geoffk@gcc.gnu.org>2004-05-30 00:49:06 +0000
commitb453c95fd3fa689a6d70e8878848e5d6531e9ac5 (patch)
tree53fb5889181940508762ddb472618440e4b6aca6 /libcpp
parent666e5d7b945c77f3bd9f3fdf00bf75f3a02e3499 (diff)
downloadgcc-b453c95fd3fa689a6d70e8878848e5d6531e9ac5.zip
gcc-b453c95fd3fa689a6d70e8878848e5d6531e9ac5.tar.gz
gcc-b453c95fd3fa689a6d70e8878848e5d6531e9ac5.tar.bz2
Index: libcpp/ChangeLog
2004-05-29 Geoffrey Keating <geoffk@apple.com> * symtab.c (ht_create): Set entries_owned. (ht_destroy): Honour entries_owned. (ht_expand): Likewise. (ht_load): New. Index: libcpp/include/ChangeLog 2004-05-29 Geoffrey Keating <geoffk@apple.com> * symtab.h (struct ht): New field 'entries_owned' (ht_load): New prototype. Index: gcc/ChangeLog 2004-05-29 Geoffrey Keating <geoffk@apple.com> * gengtype-yacc.y: Add NESTED_PTR token. (option): Record `nested_ptr' option. * gengtype-lex.l: Handle `nested_ptr' keyword. * gengtype.c (walk_type): Process `nested_ptr' option. * gengtype.h (struct nested_ptr_data): New. * doc/gty.texi (GTY Options): Document `nested_ptr' option. * stringpool.c (struct string_pool_data): Make 'entries' point to ht_identifier instead of tree. (gt_pch_save_stringpool): Don't adjust pointers. (gt_pch_restore_stringpool): Call ht_load. From-SVN: r82438
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog7
-rw-r--r--libcpp/include/ChangeLog5
-rw-r--r--libcpp/include/symtab.h9
-rw-r--r--libcpp/symtab.c24
4 files changed, 41 insertions, 4 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 8ebe6f5..71a4495 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,10 @@
+2004-05-29 Geoffrey Keating <geoffk@apple.com>
+
+ * symtab.c (ht_create): Set entries_owned.
+ (ht_destroy): Honour entries_owned.
+ (ht_expand): Likewise.
+ (ht_load): New.
+
2004-05-26 Paolo Bonzini <bonzini@gnu.org>
PR bootstrap/15651
diff --git a/libcpp/include/ChangeLog b/libcpp/include/ChangeLog
index f6c47fa..a2f4bc5 100644
--- a/libcpp/include/ChangeLog
+++ b/libcpp/include/ChangeLog
@@ -1,3 +1,8 @@
+2004-05-29 Geoffrey Keating <geoffk@apple.com>
+
+ * symtab.h (struct ht): New field 'entries_owned'
+ (ht_load): New prototype.
+
2004-05-23 Paolo Bonzini <bonzini@gnu.org>
* cpplib.h: Moved from gcc. Change header guard name.
diff --git a/libcpp/include/symtab.h b/libcpp/include/symtab.h
index 8b79332..85e285b 100644
--- a/libcpp/include/symtab.h
+++ b/libcpp/include/symtab.h
@@ -1,5 +1,5 @@
/* Hash tables.
- Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -58,6 +58,9 @@ struct ht
/* Table usage statistics. */
unsigned int searches;
unsigned int collisions;
+
+ /* Should 'entries' be freed when it is no longer needed? */
+ bool entries_owned;
};
/* Initialize the hashtable with 2 ^ order entries. */
@@ -75,6 +78,10 @@ extern hashnode ht_lookup (hash_table *, const unsigned char *,
typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
extern void ht_forall (hash_table *, ht_cb, const void *);
+/* Restore the hash table. */
+extern void ht_load (hash_table *ht, hashnode *entries,
+ unsigned int nslots, unsigned int nelements, bool own);
+
/* Dump allocation statistics to stderr. */
extern void ht_dump_statistics (hash_table *);
diff --git a/libcpp/symtab.c b/libcpp/symtab.c
index 39ceced..c80dfa2 100644
--- a/libcpp/symtab.c
+++ b/libcpp/symtab.c
@@ -1,5 +1,5 @@
/* Hash tables.
- Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -68,6 +68,7 @@ ht_create (unsigned int order)
obstack_alignment_mask (&table->stack) = 0;
table->entries = xcalloc (nslots, sizeof (hashnode));
+ table->entries_owned = true;
table->nslots = nslots;
return table;
}
@@ -78,7 +79,8 @@ void
ht_destroy (hash_table *table)
{
obstack_free (&table->stack, NULL);
- free (table->entries);
+ if (table->entries_owned)
+ free (table->entries);
free (table);
}
@@ -199,7 +201,9 @@ ht_expand (hash_table *table)
}
while (++p < limit);
- free (table->entries);
+ if (table->entries_owned)
+ free (table->entries);
+ table->entries_owned = true;
table->entries = nentries;
table->nslots = size;
}
@@ -222,6 +226,20 @@ ht_forall (hash_table *table, ht_cb cb, const void *v)
while (++p < limit);
}
+/* Restore the hash table. */
+void
+ht_load (hash_table *ht, hashnode *entries,
+ unsigned int nslots, unsigned int nelements,
+ bool own)
+{
+ if (ht->entries_owned)
+ free (ht->entries);
+ ht->entries = entries;
+ ht->nslots = nslots;
+ ht->nelements = nelements;
+ ht->entries_owned = own;
+}
+
/* Dump allocation statistics to stderr. */
void