<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>What's wrong with Buf.data() ?<br><br>Sent from my iPhone</div><div><br>On Oct 7, 2013, at 9:32 AM, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Mon, Oct 7, 2013 at 11:33 AM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: chapuni<br>
Date: Mon Oct  7 10:33:30 2013<br>
New Revision: 192103<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=192103&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=192103&view=rev</a><br>
Log:<br>
Windows/Process.inc: Fix for +Asserts. &Buf[0] is not guaranteed if size is zero.<br></blockquote><div><br></div><div>This is unsatisfying.  We shouldn't have to zero the memory after allocating it.  Is there a better way we can write this pattern?  The only thing I can think of is 'reserve(Size); push_back(L'\0')'.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Modified:<br>
    llvm/trunk/lib/Support/Windows/Process.inc<br>
<br>
Modified: llvm/trunk/lib/Support/Windows/Process.inc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=192103&r1=192102&r2=192103&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=192103&r1=192102&r2=192103&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/Windows/Process.inc (original)<br>
+++ llvm/trunk/lib/Support/Windows/Process.inc Mon Oct  7 10:33:30 2013<br>
@@ -161,7 +161,7 @@ Optional<std::string> Process::GetEnv(St<br>
   SmallVector<wchar_t, MAX_PATH> Buf;<br>
   size_t Size = MAX_PATH;<br>
   do {<br>
-    Buf.reserve(Size);<br>
+    Buf.resize(Size);<br>
     Size = GetEnvironmentVariableW(&NameUTF16[0], &Buf[0], Buf.capacity());<br>
     if (Size == 0)<br>
       return None;<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>llvm-commits mailing list</span><br><span><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a></span><br><span><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></span><br></div></blockquote></body></html>