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

Side by Side Diff: xfa/fee/fde_txtedtbuf.cpp

Issue 1951573002: Replace IFX_MemoryAllocator::Release() with delete. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 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 | « xfa/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fgas/crt/fgas_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 #include "xfa/fee/fde_txtedtbuf.h" 7 #include "xfa/fee/fde_txtedtbuf.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 m_bChanged(FALSE), 115 m_bChanged(FALSE),
116 m_pAllocator(NULL) { 116 m_pAllocator(NULL) {
117 ASSERT(m_nChunkSize); 117 ASSERT(m_nChunkSize);
118 ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize); 118 ResetChunkBuffer(FDE_DEFCHUNKCOUNT, m_nChunkSize);
119 } 119 }
120 void CFDE_TxtEdtBuf::Release() { 120 void CFDE_TxtEdtBuf::Release() {
121 delete this; 121 delete this;
122 } 122 }
123 CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() { 123 CFDE_TxtEdtBuf::~CFDE_TxtEdtBuf() {
124 Clear(TRUE); 124 Clear(TRUE);
125 m_pAllocator->Release(); 125 delete m_pAllocator;
126 m_Chunks.RemoveAll(); 126 m_Chunks.RemoveAll();
127 } 127 }
128 FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) { 128 FX_BOOL CFDE_TxtEdtBuf::SetChunkSize(int32_t nChunkSize) {
129 ASSERT(nChunkSize); 129 ASSERT(nChunkSize);
130 ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize); 130 ResetChunkBuffer(FDE_DEFCHUNKCOUNT, nChunkSize);
131 return TRUE; 131 return TRUE;
132 } 132 }
133 int32_t CFDE_TxtEdtBuf::GetChunkSize() const { 133 int32_t CFDE_TxtEdtBuf::GetChunkSize() const {
134 return m_nChunkSize; 134 return m_nChunkSize;
135 } 135 }
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return FALSE; 355 return FALSE;
356 } 356 }
357 } 357 }
358 m_bChanged = FALSE; 358 m_bChanged = FALSE;
359 return TRUE; 359 return TRUE;
360 } 360 }
361 void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount, 361 void CFDE_TxtEdtBuf::ResetChunkBuffer(int32_t nDefChunkCount,
362 int32_t nChunkSize) { 362 int32_t nChunkSize) {
363 ASSERT(nChunkSize); 363 ASSERT(nChunkSize);
364 ASSERT(nDefChunkCount); 364 ASSERT(nDefChunkCount);
365 if (m_pAllocator) { 365 delete m_pAllocator;
366 m_pAllocator->Release(); 366 m_pAllocator = nullptr;
367 m_pAllocator = NULL;
368 }
369 m_Chunks.RemoveAll(); 367 m_Chunks.RemoveAll();
370 m_nChunkSize = nChunkSize; 368 m_nChunkSize = nChunkSize;
371 int32_t nChunkLength = 369 int32_t nChunkLength =
372 sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR); 370 sizeof(FDE_CHUNKHEADER) + (m_nChunkSize - 1) * sizeof(FX_WCHAR);
373 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, nDefChunkCount, 371 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, nDefChunkCount,
374 nChunkLength); 372 nChunkLength);
375 FDE_CHUNKHEADER* lpChunkHeader = 373 FDE_CHUNKHEADER* lpChunkHeader =
376 static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(nChunkLength)); 374 static_cast<FDE_CHUNKHEADER*>(m_pAllocator->Alloc(nChunkLength));
377 ASSERT(lpChunkHeader); 375 ASSERT(lpChunkHeader);
378 lpChunkHeader->nUsed = 0; 376 lpChunkHeader->nUsed = 0;
(...skipping 20 matching lines...) Expand all
399 int32_t nCount = m_Chunks.GetSize(); 397 int32_t nCount = m_Chunks.GetSize();
400 for (; i < nCount; i++) { 398 for (; i < nCount; i++) {
401 nTotal += m_Chunks[i]->nUsed; 399 nTotal += m_Chunks[i]->nUsed;
402 if (nTotal > nIndex) { 400 if (nTotal > nIndex) {
403 break; 401 break;
404 } 402 }
405 } 403 }
406 cp.nChunkIndex = i; 404 cp.nChunkIndex = i;
407 cp.nCharIndex = m_Chunks[i]->nUsed - (nTotal - nIndex); 405 cp.nCharIndex = m_Chunks[i]->nUsed - (nTotal - nIndex);
408 } 406 }
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fgas/crt/fgas_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698