diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-17 17:42:10 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-17 17:42:10 +0000 |
commit | 24ffec381da401721f40291e7ad36e836f080b32 (patch) | |
tree | d11736fef8af73b7b6d37819f905d5ad1e594615 /gcc/cp | |
parent | cdc165b9e5fbb885a1129671a6c77bcb5f0f6be6 (diff) | |
download | gcc-24ffec381da401721f40291e7ad36e836f080b32.tar.gz |
./:
* vec.h (VEC_reserve_exact): Define.
(vec_gc_p_reserve_exact): Declare.
(vec_gc_o_reserve_exact): Declare.
(vec_heap_p_reserve_exact): Declare.
(vec_heap_o_reserve_exact): Declare.
(VEC_OP (T,A,reserve_exact)): New static inline function, three
versions.
(VEC_OP (T,A,reserve)) [all versions]: Remove handling of
negative parameter.
(VEC_OP (T,A,alloc)) [all versions]: Call ...reserve_exact.
(VEC_OP (T,A,copy)) [all versions]: Likewise.
(VEC_OP (T,a,safe_grow)) [all versions]: Likewise.
* vec.c (calculate_allocation): Add exact parameter. Change all
callers.
(vec_gc_o_reserve_1): New static function, from vec_gc_o_reserve.
(vec_gc_p_reserve, vec_gc_o_reserve): Call vec_gc_o_reserve_1.
(vec_gc_p_reserve_exact, vec_gc_o_reserve_exact): New functions.
(vec_heap_o_reserve_1): New static function, from vec_heap_o_reserve.
(vec_heap_p_reserve, vec_heap_o_reserve): Call vec_heap_o_reserve_1.
(vec_heap_p_reserve_exact): New function.
(vec_heap_o_reserve_exact): New function.
cp/:
* class.c (add_method): Call VEC_reserve_exact rather than passing
a negative size to VEC_reserve.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120861 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/class.c | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 12a3cc62680..5123c18f8b8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2007-01-17 Ian Lance Taylor <iant@google.com> + + * class.c (add_method): Call VEC_reserve_exact rather than passing + a negative size to VEC_reserve. + 2007-01-11 Simon Martin <simartin@users.sourceforge.net> PR c++/29573 diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b56ef8476de..3e0758a47b1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1071,9 +1071,15 @@ add_method (tree type, tree method, tree using_decl) if (insert_p) { + bool reallocated; + /* We only expect to add few methods in the COMPLETE_P case, so just make room for one more method in that case. */ - if (VEC_reserve (tree, gc, method_vec, complete_p ? -1 : 1)) + if (complete_p) + reallocated = VEC_reserve_exact (tree, gc, method_vec, 1); + else + reallocated = VEC_reserve (tree, gc, method_vec, 1); + if (reallocated) CLASSTYPE_METHOD_VEC (type) = method_vec; if (slot == VEC_length (tree, method_vec)) VEC_quick_push (tree, method_vec, overload); |