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

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

Issue 1136673005: Merge to XFA: Add safe FX_Alloc2D() macro (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 } 1456 }
1457 1457
1458 void Append(FX_INT32 nStart, FX_INT32 nCount) 1458 void Append(FX_INT32 nStart, FX_INT32 nCount)
1459 { 1459 {
1460 if (nStart < 0) { 1460 if (nStart < 0) {
1461 return; 1461 return;
1462 } 1462 }
1463 while (nCount > 0) { 1463 while (nCount > 0) {
1464 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); 1464 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
1465 DataList list; 1465 DataList list;
1466 list.data = FX_Alloc(FX_BYTE, temp_count * unit); 1466 list.data = FX_Alloc2D(FX_BYTE, temp_count, unit);
1467 if (!list.data) {
1468 break;
1469 }
1470 list.start = nStart; 1467 list.start = nStart;
1471 list.count = temp_count; 1468 list.count = temp_count;
1472 Append(list); 1469 Append(list);
1473 nCount -= temp_count; 1470 nCount -= temp_count;
1474 nStart += temp_count; 1471 nStart += temp_count;
1475 } 1472 }
1476 } 1473 }
1477 1474
1478 FX_LPBYTE GetAt(FX_INT32 nIndex) 1475 FX_LPBYTE GetAt(FX_INT32 nIndex)
1479 { 1476 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 FX_FLOAT c; 1620 FX_FLOAT c;
1624 FX_FLOAT d; 1621 FX_FLOAT d;
1625 FX_FLOAT e; 1622 FX_FLOAT e;
1626 FX_FLOAT f; 1623 FX_FLOAT f;
1627 FX_FLOAT g; 1624 FX_FLOAT g;
1628 FX_FLOAT h; 1625 FX_FLOAT h;
1629 FX_FLOAT i; 1626 FX_FLOAT i;
1630 }; 1627 };
1631 1628
1632 #endif 1629 #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