aboutsummaryrefslogtreecommitdiff
path: root/gcc/hash-traits.h
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2015-12-09 10:38:53 +0100
committerMartin Liska <marxin@gcc.gnu.org>2015-12-09 09:38:53 +0000
commit74fbae9278d935f5623498edc2235fcbba4f9578 (patch)
treefb7947be8a3f4d0a15355104b20479f9e247ed09 /gcc/hash-traits.h
parentd2b04f0b7beb7d153e31fb956e4580dbf6c99c8c (diff)
downloadgcc-74fbae9278d935f5623498edc2235fcbba4f9578.zip
gcc-74fbae9278d935f5623498edc2235fcbba4f9578.tar.gz
gcc-74fbae9278d935f5623498edc2235fcbba4f9578.tar.bz2
Fix newly introduced memory leak in
* hash-traits.h (struct typed_delete_remove): New function. (typed_delete_remove ::remove): Likewise. * tree-ssa-loop-ivopts.c (struct iv_common_cand): Replace auto_vec with vec. (record_common_cand): Replace XNEW with operator new. From-SVN: r231448
Diffstat (limited to 'gcc/hash-traits.h')
-rw-r--r--gcc/hash-traits.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h
index 450354a..3997ede 100644
--- a/gcc/hash-traits.h
+++ b/gcc/hash-traits.h
@@ -38,6 +38,23 @@ typed_free_remove <Type>::remove (Type *p)
free (p);
}
+/* Helpful type for removing with delete. */
+
+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. */
@@ -260,6 +277,12 @@ struct nofree_ptr_hash : pointer_hash <T>, typed_noop_remove <T *> {};
template <typename T>
struct free_ptr_hash : pointer_hash <T>, typed_free_remove <T> {};
+/* Traits for pointer elements that should be freed via delete operand when an
+ element is deleted. */
+
+template <typename T>
+struct delete_ptr_hash : pointer_hash <T>, typed_delete_remove <T> {};
+
/* Traits for elements that point to gc memory. The pointed-to data
must be kept across collections. */