Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: compiled/String.h

Issue 29669631: Noissue - Zero size OwnedString should be INVALID (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Jan. 15, 2018, 10:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (negative) 398 if (negative)
399 mBuf[pos++] = '-'; 399 mBuf[pos++] = '-';
400 400
401 for (int i = size - 1; i >= 0; i--) 401 for (int i = size - 1; i >= 0; i--)
402 { 402 {
403 mBuf[pos + i] = '0' + (num % 10); 403 mBuf[pos + i] = '0' + (num % 10);
404 num /= 10; 404 num /= 10;
405 } 405 }
406 } 406 }
407 }; 407 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld