]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use a vector in objc_msgcall_operation::evaluate
authorTom Tromey <tromey@adacore.com>
Fri, 14 Nov 2025 20:42:11 +0000 (13:42 -0700)
committerTom Tromey <tromey@adacore.com>
Mon, 1 Dec 2025 19:36:35 +0000 (12:36 -0700)
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

index 5d1907f837e8e1eab65bda51f2730732d8111b4e..a2da901877fbdc3f1b3e3e4a07585f0287db945b 100644 (file)
@@ -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<operation_up> &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<operation_up> &args = std::get<2> (m_storage);
+  std::vector<value *> 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 *