OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 mBuf = new value_type[length()]; | 288 mBuf = new value_type[length()]; |
289 annotate_address(mBuf, "String"); | 289 annotate_address(mBuf, "String"); |
290 } | 290 } |
291 else | 291 else |
292 mBuf = nullptr; | 292 mBuf = nullptr; |
293 } | 293 } |
294 | 294 |
295 explicit OwnedString(const String& str) | 295 explicit OwnedString(const String& str) |
296 : OwnedString(str.length()) | 296 : OwnedString(str.length()) |
297 { | 297 { |
298 if (length()) | 298 if (!str.is_invalid() && !length()) |
| 299 mLen = length() | READ_WRITE; |
| 300 else if (length()) |
299 std::memcpy(mBuf, str.mBuf, sizeof(value_type) * length()); | 301 std::memcpy(mBuf, str.mBuf, sizeof(value_type) * length()); |
300 } | 302 } |
301 | 303 |
302 OwnedString(const OwnedString& str) | 304 OwnedString(const OwnedString& str) |
303 : OwnedString(static_cast<const String&>(str)) | 305 : OwnedString(static_cast<const String&>(str)) |
304 { | 306 { |
305 } | 307 } |
306 | 308 |
307 explicit OwnedString(const value_type* str, size_type len) | 309 explicit OwnedString(const value_type* str, size_type len) |
308 : OwnedString(DependentString(str, len)) | 310 : OwnedString(DependentString(str, len)) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 if (negative) | 413 if (negative) |
412 mBuf[pos++] = '-'; | 414 mBuf[pos++] = '-'; |
413 | 415 |
414 for (int i = size - 1; i >= 0; i--) | 416 for (int i = size - 1; i >= 0; i--) |
415 { | 417 { |
416 mBuf[pos + i] = '0' + (num % 10); | 418 mBuf[pos + i] = '0' + (num % 10); |
417 num /= 10; | 419 num /= 10; |
418 } | 420 } |
419 } | 421 } |
420 }; | 422 }; |
OLD | NEW |