1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #include "JBig2_Object.h" 8 #include "JBig2_Module.h" 9 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule, FX_LPCSTR filename, int line) 10 { 11 CJBig2_Object *p; 12 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); 13 p->m_pModule = pModule; 14 return p; 15 } 16 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule, FX_LPCSTR filename, int line) 17 { 18 pModule->JBig2_Free(p); 19 } 20 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule) 21 { 22 CJBig2_Object *p; 23 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); 24 p->m_pModule = pModule; 25 return p; 26 } 27 void CJBig2_Object::operator delete(void *p) 28 { 29 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); 30 } 31 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule) 32 { 33 pModule->JBig2_Free(p); 34 } 35 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t unit_size, 36 FX_LPCSTR filename, int line) 37 { 38 void *p; 39 FX_BYTE *pCur, *pEnd; 40 p = (FX_BYTE *)pModule->JBig2_Malloc((FX_DWORD)size); 41 pCur = (FX_BYTE *)p; 42 pEnd = pCur + size; 43 for(; pCur < pEnd; pCur += unit_size) { 44 ((CJBig2_Object *)pCur)->m_pModule = pModule; 45 } 46 return p; 47 } 48 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t unit_size, 49 FX_LPCSTR filename, int line) 50 { 51 pModule->JBig2_Free(p); 52 } 53 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t unit_size) 54 { 55 void *p; 56 FX_BYTE *pCur, *pEnd; 57 p = (FX_BYTE *)pModule->JBig2_Malloc((FX_DWORD)size); 58 pCur = (FX_BYTE *)p; 59 pEnd = pCur + size; 60 for(; pCur < pEnd; pCur += unit_size) { 61 ((CJBig2_Object *)pCur)->m_pModule = pModule; 62 } 63 return p; 64 } 65 void CJBig2_Object::operator delete[](void* p) 66 { 67 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); 68 } 69 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t unit_size) 70 { 71 pModule->JBig2_Free(p); 72 } 73