From f75bdb181576e4a4cf8291706a0db86c687e5fc3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 11 Dec 2015 16:26:00 -0800 Subject: XFA: avoid multiplications in FX_Allocs In some cases, we can use the safe FX_Alloc2D, in others there's an extra multiplication by the size of the type. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1519233002 . --- xfa/src/fxgraphics/src/fx_graphics.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'xfa/src/fxgraphics') diff --git a/xfa/src/fxgraphics/src/fx_graphics.cpp b/xfa/src/fxgraphics/src/fx_graphics.cpp index 53d001e9d7..d983b5d6f8 100644 --- a/xfa/src/fxgraphics/src/fx_graphics.cpp +++ b/xfa/src/fxgraphics/src/fx_graphics.cpp @@ -534,8 +534,7 @@ FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, _FX_RETURN_VALUE_IF_FAIL(_renderDevice, FX_ERR_Property_Invalid); int32_t length = text.GetLength(); FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = - FX_Alloc(FXTEXT_CHARPOS, length * sizeof(FXTEXT_CHARPOS)); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); CalcTextInfo(text, charCodes, charPos, rect); FX_Free(charPos); FX_Free(charCodes); @@ -867,8 +866,7 @@ FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, CFX_Matrix* matrix) { int32_t length = text.GetLength(); FX_DWORD* charCodes = FX_Alloc(FX_DWORD, length); - FXTEXT_CHARPOS* charPos = - FX_Alloc(FXTEXT_CHARPOS, length * sizeof(FXTEXT_CHARPOS)); + FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); CFX_RectF rect; rect.Set(point.x, point.y, 0, 0); CalcTextInfo(text, charCodes, charPos, rect); -- cgit v1.2.3