This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA v2 4/4] Use std::vector in struct catch_syscall_inferior_data


On 2017-07-19 22:32, Tom Tromey wrote:
@@ -104,31 +106,17 @@ insert_catch_syscall (struct bp_location *bl)
 	{
           int elem;

-	  if (iter >= VEC_length (int, inf_data->syscalls_counts))
-	    {
- int old_size = VEC_length (int, inf_data->syscalls_counts);
-              uintptr_t vec_addr_offset
-		= old_size * ((uintptr_t) sizeof (int));
-              uintptr_t vec_addr;
- VEC_safe_grow (int, inf_data->syscalls_counts, iter + 1);
-              vec_addr = ((uintptr_t) VEC_address (int,
-						  inf_data->syscalls_counts)
-			  + vec_addr_offset);
-              memset ((void *) vec_addr, 0,
-                      (iter + 1 - old_size) * sizeof (int));
-	    }
-          elem = VEC_index (int, inf_data->syscalls_counts, iter);
-          VEC_replace (int, inf_data->syscalls_counts, iter, ++elem);
+	  if (iter >= inf_data->syscalls_counts.size ())
+	    inf_data->syscalls_counts.resize (iter + 1);

I wasn't sure at first if this would insert zeros, but after some searching it seems like the new elements are value-initialized, so it's fine.

LGTM too.

Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]