| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 void grow(size_type additionalSize) | 274 void grow(size_type additionalSize) |
| 275 { | 275 { |
| 276 OwnedString newValue(length() + additionalSize); | 276 OwnedString newValue(length() + additionalSize); |
| 277 if (length() > 0) | 277 if (length() > 0) |
| 278 std::memcpy(newValue.mBuf, mBuf, sizeof(value_type) * length()); | 278 std::memcpy(newValue.mBuf, mBuf, sizeof(value_type) * length()); |
| 279 *this = std::move(newValue); | 279 *this = std::move(newValue); |
| 280 } | 280 } |
| 281 | 281 |
| 282 public: | 282 public: |
| 283 explicit OwnedString(size_type len = 0) | 283 explicit OwnedString(size_type len = 0) |
| 284 : String(nullptr, len, READ_WRITE) | 284 : String(nullptr, len, len ? READ_WRITE : INVALID) |
| 285 { | 285 { |
| 286 if (len) | 286 if (len) |
| 287 { | 287 { |
| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 317 str.mBuf = nullptr; | 317 str.mBuf = nullptr; |
| 318 str.mLen = READ_WRITE | 0; | 318 str.mLen = READ_WRITE | 0; |
| 319 } | 319 } |
| 320 | 320 |
| 321 ~OwnedString() | 321 ~OwnedString() |
| 322 { | 322 { |
| 323 if (mBuf) | 323 if (mBuf) |
| 324 delete[] mBuf; | 324 delete[] mBuf; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void reset(const String& str) |
| 328 { |
| 329 *this = str; |
| 330 } |
| 331 |
| 327 OwnedString& operator=(const String& str) | 332 OwnedString& operator=(const String& str) |
| 328 { | 333 { |
| 329 *this = OwnedString(str); | 334 *this = OwnedString(str); |
| 330 return *this; | 335 return *this; |
| 331 } | 336 } |
| 332 | 337 |
| 333 OwnedString& operator=(const OwnedString& str) | 338 OwnedString& operator=(const OwnedString& str) |
| 334 { | 339 { |
| 335 *this = OwnedString(str); | 340 *this = OwnedString(str); |
| 336 return *this; | 341 return *this; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 if (negative) | 403 if (negative) |
| 399 mBuf[pos++] = '-'; | 404 mBuf[pos++] = '-'; |
| 400 | 405 |
| 401 for (int i = size - 1; i >= 0; i--) | 406 for (int i = size - 1; i >= 0; i--) |
| 402 { | 407 { |
| 403 mBuf[pos + i] = '0' + (num % 10); | 408 mBuf[pos + i] = '0' + (num % 10); |
| 404 num /= 10; | 409 num /= 10; |
| 405 } | 410 } |
| 406 } | 411 } |
| 407 }; | 412 }; |
| OLD | NEW |