From 4dfb6da780be59adfb0750768df6fb86d4b9960a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 14 Nov 2025 13:42:11 -0700 Subject: [PATCH] Use a vector in objc_msgcall_operation::evaluate This changes objc_msgcall_operation::evaluate to use a std::vector rather than XALLOCAVEC. alloca is bad and should generally be avoided; and anyway there's no justification for it here. --- gdb/eval.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/eval.c b/gdb/eval.c index 5d1907f837e..a2da901877f 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2238,17 +2238,16 @@ objc_msgcall_operation::evaluate (struct type *expect_type, sub_no_side = EVAL_AVOID_SIDE_EFFECTS; else sub_no_side = noside; - std::vector &args = std::get<2> (m_storage); - value **argvec = XALLOCAVEC (struct value *, args.size () + 2); - argvec[0] = nullptr; - argvec[1] = nullptr; - for (int i = 0; i < args.size (); ++i) - argvec[i + 2] = args[i]->evaluate_with_coercion (exp, sub_no_side); - return eval_op_objc_msgcall (expect_type, exp, noside, std:: - get<0> (m_storage), target, - gdb::make_array_view (argvec, - args.size () + 2)); + std::vector &args = std::get<2> (m_storage); + std::vector argvec; + argvec.push_back (nullptr); + argvec.push_back (nullptr); + for (const operation_up &iter : args) + argvec.push_back (iter->evaluate_with_coercion (exp, sub_no_side)); + + return eval_op_objc_msgcall (expect_type, exp, noside, + std::get<0> (m_storage), target, argvec); } value * -- 2.47.3