Hello, The hash table type can handle creation and removal of entries with malloc/free. This patchlet adds support for using new/delete. It's useful for hash table entry types that have constructors (and/or destructors), to prevent the user from having to type boilerplate code to initialize them over and over again. This is used by the patch that follows this one.
gcc/ * hash-table.h (struct typed_delete_remove): New type. (typed_delete_remove::remove): Implement this using the delete operator. --- gcc/hash-table.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gcc/hash-table.h b/gcc/hash-table.h index 206423d..884840c 100644 --- a/gcc/hash-table.h +++ b/gcc/hash-table.h @@ -235,6 +235,22 @@ typed_free_remove <Type>::remove (Type *p) free (p); } +/* Helpful type for removing entries with the delete operator. */ + +template <typename Type> +struct typed_delete_remove +{ + static inline void remove (Type *p); +}; + +/* Remove with delete. */ + +template <typename Type> +inline void +typed_delete_remove <Type>::remove (Type *p) +{ + delete p; +} /* Helpful type for a no-op remove. */ -- 1.7.11.7 -- Dodji