From 674d4e36956cf84ecf7fe027325f717ba734d885 Mon Sep 17 00:00:00 2001
From: jD91mZM2 <me@krake.one>
Date: Sat, 30 Jun 2018 09:25:05 +0200
Subject: [PATCH] Preallocate because why not

---
 src/unistd/src/lib.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/unistd/src/lib.rs b/src/unistd/src/lib.rs
index 6a6bc339..2071c6f4 100644
--- a/src/unistd/src/lib.rs
+++ b/src/unistd/src/lib.rs
@@ -173,7 +173,15 @@ pub unsafe extern "C" fn execve(
             env = env.offset(1);
         }
 
-        let mut args: Vec<[usize; 2]> = Vec::new();
+        let mut len = 0;
+        for i in 0.. {
+            if (*arg.offset(i)).is_null() {
+                len = i;
+                break;
+            }
+        }
+
+        let mut args: Vec<[usize; 2]> = Vec::with_capacity(len);
         let mut arg = argv;
         while !(*arg).is_null() {
             args.push([*arg as usize, c_str(*arg).len()]);
-- 
GitLab