Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: core/include/fxcrt/fx_basic.h

Issue 1052553006: Remove checks in fxcrt now that FX_NEW can't return 0. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_util.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #ifndef _FX_BASIC_H_ 7 #ifndef _FX_BASIC_H_
8 #define _FX_BASIC_H_ 8 #define _FX_BASIC_H_
9 9
10 #include "fx_memory.h" 10 #include "fx_memory.h"
(...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 } 1264 }
1265 } 1265 }
1266 1266
1267 ObjClass* New() 1267 ObjClass* New()
1268 { 1268 {
1269 if (m_pObject) { 1269 if (m_pObject) {
1270 m_pObject->m_RefCount --; 1270 m_pObject->m_RefCount --;
1271 if (m_pObject->m_RefCount <= 0) { 1271 if (m_pObject->m_RefCount <= 0) {
1272 delete m_pObject; 1272 delete m_pObject;
1273 } 1273 }
1274 m_pObject = NULL;
1275 } 1274 }
1276 m_pObject = FX_NEW CountedObj; 1275 m_pObject = new CountedObj;
1277 if (!m_pObject) {
1278 return NULL;
1279 }
1280 m_pObject->m_RefCount = 1; 1276 m_pObject->m_RefCount = 1;
1281 return m_pObject; 1277 return m_pObject;
1282 } 1278 }
1283 1279
1284 void operator = (const Ref& ref) 1280 void operator = (const Ref& ref)
1285 { 1281 {
1286 if (ref.m_pObject) { 1282 if (ref.m_pObject) {
1287 ref.m_pObject->m_RefCount ++; 1283 ref.m_pObject->m_RefCount ++;
1288 } 1284 }
1289 if (m_pObject) { 1285 if (m_pObject) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 } 1320 }
1325 1321
1326 FX_BOOL NotNull() const 1322 FX_BOOL NotNull() const
1327 { 1323 {
1328 return m_pObject != NULL; 1324 return m_pObject != NULL;
1329 } 1325 }
1330 1326
1331 ObjClass* GetModify() 1327 ObjClass* GetModify()
1332 { 1328 {
1333 if (m_pObject == NULL) { 1329 if (m_pObject == NULL) {
1334 m_pObject = FX_NEW CountedObj; 1330 m_pObject = new CountedObj;
1335 if (m_pObject) { 1331 m_pObject->m_RefCount = 1;
1336 m_pObject->m_RefCount = 1;
1337 }
1338 } else if (m_pObject->m_RefCount > 1) { 1332 } else if (m_pObject->m_RefCount > 1) {
1339 m_pObject->m_RefCount --; 1333 m_pObject->m_RefCount --;
1340 CountedObj* pOldObject = m_pObject; 1334 CountedObj* pOldObject = m_pObject;
1341 m_pObject = NULL; 1335 m_pObject = new CountedObj(*pOldObject);
1342 m_pObject = FX_NEW CountedObj(*pOldObject); 1336 m_pObject->m_RefCount = 1;
1343 if (m_pObject) {
1344 m_pObject->m_RefCount = 1;
1345 }
1346 } 1337 }
1347 return m_pObject; 1338 return m_pObject;
1348 } 1339 }
1349 1340
1350 void SetNull() 1341 void SetNull()
1351 { 1342 {
1352 if (m_pObject == NULL) { 1343 if (m_pObject == NULL) {
1353 return; 1344 return;
1354 } 1345 }
1355 m_pObject->m_RefCount --; 1346 m_pObject->m_RefCount --;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1642 FX_FLOAT c; 1633 FX_FLOAT c;
1643 FX_FLOAT d; 1634 FX_FLOAT d;
1644 FX_FLOAT e; 1635 FX_FLOAT e;
1645 FX_FLOAT f; 1636 FX_FLOAT f;
1646 FX_FLOAT g; 1637 FX_FLOAT g;
1647 FX_FLOAT h; 1638 FX_FLOAT h;
1648 FX_FLOAT i; 1639 FX_FLOAT i;
1649 }; 1640 };
1650 1641
1651 #endif 1642 #endif
OLDNEW
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_util.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698