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

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

Issue 1143663004: Add safe FX_Alloc2D() macro (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Drop one file, indent. Created 5 years, 7 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/include/fxcrt/fx_memory.h » ('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 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 } 1447 }
1448 1448
1449 void Append(FX_INT32 nStart, FX_INT32 nCount) 1449 void Append(FX_INT32 nStart, FX_INT32 nCount)
1450 { 1450 {
1451 if (nStart < 0) { 1451 if (nStart < 0) {
1452 return; 1452 return;
1453 } 1453 }
1454 while (nCount > 0) { 1454 while (nCount > 0) {
1455 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); 1455 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
1456 DataList list; 1456 DataList list;
1457 list.data = FX_Alloc(FX_BYTE, temp_count * unit); 1457 list.data = FX_Alloc2D(FX_BYTE, temp_count, unit);
1458 if (!list.data) {
1459 break;
1460 }
1461 list.start = nStart; 1458 list.start = nStart;
1462 list.count = temp_count; 1459 list.count = temp_count;
1463 Append(list); 1460 Append(list);
1464 nCount -= temp_count; 1461 nCount -= temp_count;
1465 nStart += temp_count; 1462 nStart += temp_count;
1466 } 1463 }
1467 } 1464 }
1468 1465
1469 FX_LPBYTE GetAt(FX_INT32 nIndex) 1466 FX_LPBYTE GetAt(FX_INT32 nIndex)
1470 { 1467 {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 FX_FLOAT c; 1604 FX_FLOAT c;
1608 FX_FLOAT d; 1605 FX_FLOAT d;
1609 FX_FLOAT e; 1606 FX_FLOAT e;
1610 FX_FLOAT f; 1607 FX_FLOAT f;
1611 FX_FLOAT g; 1608 FX_FLOAT g;
1612 FX_FLOAT h; 1609 FX_FLOAT h;
1613 FX_FLOAT i; 1610 FX_FLOAT i;
1614 }; 1611 };
1615 1612
1616 #endif 1613 #endif
OLDNEW
« no previous file with comments | « no previous file | core/include/fxcrt/fx_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698