]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/strutils.cxx
HTTP: Rename urlretrieve/urlload to save/load.
[simgear.git] / simgear / misc / strutils.cxx
index 34d930745cae6c02bc2213a709825041b6431dee..10a4c67941cd1031c528464aa7ebb95ed3ad3109 100644 (file)
@@ -370,14 +370,13 @@ static bool is_whitespace(unsigned char c) {
     return ((c == ' ') || (c == '\r') || (c == '\n'));
 }
 
-std::string decodeBase64(const std::string& encoded_string)
+void decodeBase64(const std::string& encoded_string, std::vector<unsigned char>& ret)
 {
   int in_len = encoded_string.size();
   int i = 0;
   int j = 0;
   int in_ = 0;
   unsigned char char_array_4[4], char_array_3[3];
-  std::string ret;
   
   while (in_len-- && ( encoded_string[in_] != '=')) {
     if (is_whitespace( encoded_string[in_])) {
@@ -399,7 +398,7 @@ std::string decodeBase64(const std::string& encoded_string)
       char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
       
       for (i = 0; (i < 3); i++)
-        ret += char_array_3[i];
+        ret.push_back(char_array_3[i]);
       i = 0;
     }
   }
@@ -415,10 +414,8 @@ std::string decodeBase64(const std::string& encoded_string)
     char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
     char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
     
-    for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
+    for (j = 0; (j < i - 1); j++) ret.push_back(char_array_3[j]);
   }
-  
-  return ret;
 }  
 
 const char hexChar[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};