Move JDWP to std::vector<iovec> to remove runtime/arrays warning

Change-Id: I8494a25a65de4ebac2b1f4f41c0f5eedf117b7ac
diff --git a/runtime/debugger.cc b/runtime/debugger.cc
index 9e9dd87..deed540 100644
--- a/runtime/debugger.cc
+++ b/runtime/debugger.cc
@@ -3071,7 +3071,7 @@
   DdmSendChunk(type, bytes.size(), &bytes[0]);
 }
 
-void Dbg::DdmSendChunkV(uint32_t type, const struct iovec* iov, int iov_count) {
+void Dbg::DdmSendChunkV(uint32_t type, const iovec* iov, int iov_count) {
   if (gJdwpState == NULL) {
     VLOG(jdwp) << "Debugger thread not active, ignoring DDM send: " << type;
   } else {
diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h
index 6a5d0d1..1735852 100644
--- a/runtime/jdwp/jdwp.h
+++ b/runtime/jdwp/jdwp.h
@@ -288,7 +288,7 @@
   void UnregisterEvent(JdwpEvent* pEvent)
       EXCLUSIVE_LOCKS_REQUIRED(event_list_lock_)
       SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
-  void SendBufferedRequest(uint32_t type, const iovec* iov, int iov_count);
+  void SendBufferedRequest(uint32_t type, const std::vector<iovec>& iov);
 
  public: // TODO: fix privacy
   const JdwpOptions* options_;
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index 546c637..ef5a7d3 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -1046,10 +1046,10 @@
    * "Wrap" the contents of the iovec with a JDWP/DDMS header.  We do
    * this by creating a new copy of the vector with space for the header.
    */
-  iovec wrapiov[iov_count+1];  // NOLINT(runtime/arrays) iov_count < 10
+  std::vector<iovec> wrapiov;
+  wrapiov.push_back(iovec());
   for (int i = 0; i < iov_count; i++) {
-    wrapiov[i+1].iov_base = iov[i].iov_base;
-    wrapiov[i+1].iov_len = iov[i].iov_len;
+    wrapiov.push_back(iov[i]);
     dataLen += iov[i].iov_len;
   }
 
@@ -1080,11 +1080,11 @@
   if (safe_to_release_mutator_lock_over_send) {
     // Change state to waiting to allow GC, ... while we're sending.
     self->TransitionFromRunnableToSuspended(kWaitingForDebuggerSend);
-    SendBufferedRequest(type, wrapiov, iov_count + 1);
+    SendBufferedRequest(type, wrapiov);
     self->TransitionFromSuspendedToRunnable();
   } else {
     // Send and possibly block GC...
-    SendBufferedRequest(type, wrapiov, iov_count + 1);
+    SendBufferedRequest(type, wrapiov);
   }
 }
 
diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc
index 3b6dd81..790bcb5 100644
--- a/runtime/jdwp/jdwp_main.cc
+++ b/runtime/jdwp/jdwp_main.cc
@@ -132,16 +132,16 @@
 /*
  * Write a buffered packet. Grabs a mutex to assure atomicity.
  */
-ssize_t JdwpNetStateBase::WriteBufferedPacket(const iovec* iov, int iov_count) {
+ssize_t JdwpNetStateBase::WriteBufferedPacket(const std::vector<iovec>& iov) {
   MutexLock mu(Thread::Current(), socket_lock_);
-  return TEMP_FAILURE_RETRY(writev(clientSock, iov, iov_count));
+  return TEMP_FAILURE_RETRY(writev(clientSock, &iov[0], iov.size()));
 }
 
 bool JdwpState::IsConnected() {
   return netState != NULL && netState->IsConnected();
 }
 
-void JdwpState::SendBufferedRequest(uint32_t type, const iovec* iov, int iov_count) {
+void JdwpState::SendBufferedRequest(uint32_t type, const std::vector<iovec>& iov) {
   if (netState->clientSock < 0) {
     // Can happen with some DDMS events.
     VLOG(jdwp) << "Not sending JDWP packet: no debugger attached!";
@@ -149,12 +149,12 @@
   }
 
   size_t expected = 0;
-  for (int i = 0; i < iov_count; ++i) {
+  for (size_t i = 0; i < iov.size(); ++i) {
     expected += iov[i].iov_len;
   }
 
   errno = 0;
-  ssize_t actual = netState->WriteBufferedPacket(iov, iov_count);
+  ssize_t actual = netState->WriteBufferedPacket(iov);
   if (static_cast<size_t>(actual) != expected) {
     PLOG(ERROR) << StringPrintf("Failed to send JDWP packet %c%c%c%c to debugger (%d of %d)",
                                 static_cast<uint8_t>(type >> 24),
diff --git a/runtime/jdwp/jdwp_priv.h b/runtime/jdwp/jdwp_priv.h
index 557632c..f919f97 100644
--- a/runtime/jdwp/jdwp_priv.h
+++ b/runtime/jdwp/jdwp_priv.h
@@ -70,7 +70,7 @@
   void Close();
 
   ssize_t WritePacket(ExpandBuf* pReply);
-  ssize_t WriteBufferedPacket(const iovec* iov, int iov_count);
+  ssize_t WriteBufferedPacket(const std::vector<iovec>& iov);
 
   int clientSock; // Active connection to debugger.