Bug 737164 part C - switch various in-tree callers which are using fallible strings to keep using them
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 08 May 2012 13:55:24 -0400
changeset 93751 971a0d129ff327982d8616a4c506f8133066b8c4
parent 93750 b6d494a571220166bac1636290c4364730e659c2
child 93752 33aee46739d791f7c309d7e84b273dda2509db70
push id22667
push userjdrew@mozilla.com
push dateFri, 11 May 2012 01:26:16 +0000
treeherdermozilla-central@e6a9572b48f7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs737164
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 737164 part C - switch various in-tree callers which are using fallible strings to keep using them
content/base/src/nsXMLHttpRequest.cpp
services/crypto/component/nsSyncJPAKE.cpp
toolkit/components/places/Helpers.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -876,17 +876,17 @@ nsXMLHttpRequest::AppendToResponseText(c
 {
   NS_ENSURE_STATE(mDecoder);
 
   PRInt32 destBufferLen;
   nsresult rv = mDecoder->GetMaxLength(aSrcBuffer, aSrcBufferLen,
                                        &destBufferLen);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!mResponseText.SetCapacity(mResponseText.Length() + destBufferLen)) {
+  if (!mResponseText.SetCapacity(mResponseText.Length() + destBufferLen, fallible_t())) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   PRUnichar* destBuffer = mResponseText.BeginWriting() + mResponseText.Length();
 
   PRInt32 totalChars = mResponseText.Length();
 
   // This code here is basically a copy of a similar thing in
--- a/services/crypto/component/nsSyncJPAKE.cpp
+++ b/services/crypto/component/nsSyncJPAKE.cpp
@@ -45,16 +45,18 @@
 #include <secmodt.h>
 #include <secport.h>
 #include <secerr.h>
 #include <nsDebug.h>
 #include <nsError.h>
 #include <base64.h>
 #include <nsString.h>
 
+using mozilla::fallible_t;
+
 static bool
 hex_from_2char(const unsigned char *c2, unsigned char *byteval)
 {
   int i;
   unsigned char offset;
   *byteval = 0;
   for (i=0; i<2; i++) {
     if (c2[i] >= '0' && c2[i] <= '9') {
@@ -100,17 +102,17 @@ fromHexString(const nsACString & str, un
   }
   return NS_OK;
 }
 
 static bool
 toHexString(const unsigned char * str, unsigned len, nsACString & out)
 {
   static const char digits[] = "0123456789ABCDEF";
-  if (!out.SetCapacity(2 * len))
+  if (!out.SetCapacity(2 * len, fallible_t()))
     return false;
   out.SetLength(0);
   for (unsigned i = 0; i < len; ++i) {
     out.Append(digits[str[i] >> 4]);
     out.Append(digits[str[i] & 0x0f]);
   }
   return true;
 }
@@ -327,17 +329,17 @@ NS_IMETHODIMP nsSyncJPAKE::Round2(const 
 static nsresult
 setBase64(const unsigned char * data, unsigned len, nsACString & out)
 {
   nsresult rv = NS_OK;
   const char * base64 = BTOA_DataToAscii(data, len);
   
   if (base64 != NULL) {
     size_t len = PORT_Strlen(base64);
-    if (out.SetCapacity(len)) {
+    if (out.SetCapacity(len, fallible_t())) {
       out.SetLength(0);
       out.Append(base64, len);
       PORT_Free((void*) base64);
     } else {
       rv = NS_ERROR_OUT_OF_MEMORY;
     }
   } else {
     rv = NS_ERROR_OUT_OF_MEMORY;
--- a/toolkit/components/places/Helpers.cpp
+++ b/toolkit/components/places/Helpers.cpp
@@ -244,17 +244,18 @@ Base64urlEncode(const PRUint8* aBytes,
                 PRUint32 aNumBytes,
                 nsCString& _result)
 {
   // SetLength does not set aside space for NULL termination.  PL_Base64Encode
   // will not NULL terminate, however, nsCStrings must be NULL terminated.  As a
   // result, we set the capacity to be one greater than what we need, and the
   // length to our desired length.
   PRUint32 length = (aNumBytes + 2) / 3 * 4; // +2 due to integer math.
-  NS_ENSURE_TRUE(_result.SetCapacity(length + 1), NS_ERROR_OUT_OF_MEMORY);
+  NS_ENSURE_TRUE(_result.SetCapacity(length + 1, fallible_t()),
+                 NS_ERROR_OUT_OF_MEMORY);
   _result.SetLength(length);
   (void)PL_Base64Encode(reinterpret_cast<const char*>(aBytes), aNumBytes,
                         _result.BeginWriting());
 
   // base64url encoding is defined in RFC 4648.  It replaces the last two
   // alphabet characters of base64 encoding with '-' and '_' respectively.
   _result.ReplaceChar('+', '-');
   _result.ReplaceChar('/', '_');