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

Side by Side Diff: compiled/String.h

Issue 29676711: Noissue - OwnedString::reset() and OwnedString::erase() (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Jan. 22, 2018, 4:30 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
332 void erase()
333 {
334 if (mBuf)
335 delete[] mBuf;
336 mBuf = nullptr;
337 mLen = DELETED;
338 }
339
327 OwnedString& operator=(const String& str) 340 OwnedString& operator=(const String& str)
328 { 341 {
329 *this = OwnedString(str); 342 *this = OwnedString(str);
330 return *this; 343 return *this;
331 } 344 }
332 345
333 OwnedString& operator=(const OwnedString& str) 346 OwnedString& operator=(const OwnedString& str)
334 { 347 {
335 *this = OwnedString(str); 348 *this = OwnedString(str);
336 return *this; 349 return *this;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (negative) 411 if (negative)
399 mBuf[pos++] = '-'; 412 mBuf[pos++] = '-';
400 413
401 for (int i = size - 1; i >= 0; i--) 414 for (int i = size - 1; i >= 0; i--)
402 { 415 {
403 mBuf[pos + i] = '0' + (num % 10); 416 mBuf[pos + i] = '0' + (num % 10);
404 num /= 10; 417 num /= 10;
405 } 418 }
406 } 419 }
407 }; 420 };
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