OLD | NEW |
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 "JBig2_Object.h" | 7 #include "JBig2_Object.h" |
8 #include "JBig2_Module.h" | 8 #include "JBig2_Module.h" |
9 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule, FX_LPCSTR
filename, int line) | 9 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule, const FX_
CHAR* filename, int line) |
10 { | 10 { |
11 CJBig2_Object *p; | 11 CJBig2_Object *p; |
12 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); | 12 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); |
13 p->m_pModule = pModule; | 13 p->m_pModule = pModule; |
14 return p; | 14 return p; |
15 } | 15 } |
16 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule, FX_LPCSTR f
ilename, int line) | 16 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule, const FX_CH
AR* filename, int line) |
17 { | 17 { |
18 pModule->JBig2_Free(p); | 18 pModule->JBig2_Free(p); |
19 } | 19 } |
20 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule) | 20 void *CJBig2_Object::operator new(size_t size, CJBig2_Module *pModule) |
21 { | 21 { |
22 CJBig2_Object *p; | 22 CJBig2_Object *p; |
23 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); | 23 p = (CJBig2_Object *)pModule->JBig2_Malloc((FX_DWORD)size); |
24 p->m_pModule = pModule; | 24 p->m_pModule = pModule; |
25 return p; | 25 return p; |
26 } | 26 } |
27 void CJBig2_Object::operator delete(void *p) | 27 void CJBig2_Object::operator delete(void *p) |
28 { | 28 { |
29 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); | 29 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); |
30 } | 30 } |
31 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule) | 31 void CJBig2_Object::operator delete(void *p, CJBig2_Module *pModule) |
32 { | 32 { |
33 pModule->JBig2_Free(p); | 33 pModule->JBig2_Free(p); |
34 } | 34 } |
35 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t
unit_size, | 35 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t
unit_size, |
36 FX_LPCSTR filename, int line) | 36 const FX_CHAR* filename, int line) |
37 { | 37 { |
38 void *p; | 38 void *p; |
39 uint8_t *pCur, *pEnd; | 39 uint8_t *pCur, *pEnd; |
40 p = (uint8_t *)pModule->JBig2_Malloc((FX_DWORD)size); | 40 p = (uint8_t *)pModule->JBig2_Malloc((FX_DWORD)size); |
41 pCur = (uint8_t *)p; | 41 pCur = (uint8_t *)p; |
42 pEnd = pCur + size; | 42 pEnd = pCur + size; |
43 for(; pCur < pEnd; pCur += unit_size) { | 43 for(; pCur < pEnd; pCur += unit_size) { |
44 ((CJBig2_Object *)pCur)->m_pModule = pModule; | 44 ((CJBig2_Object *)pCur)->m_pModule = pModule; |
45 } | 45 } |
46 return p; | 46 return p; |
47 } | 47 } |
48 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t un
it_size, | 48 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t un
it_size, |
49 FX_LPCSTR filename, int line) | 49 const FX_CHAR* filename, int line) |
50 { | 50 { |
51 pModule->JBig2_Free(p); | 51 pModule->JBig2_Free(p); |
52 } | 52 } |
53 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t
unit_size) | 53 void *CJBig2_Object::operator new[](size_t size, CJBig2_Module *pModule, size_t
unit_size) |
54 { | 54 { |
55 void *p; | 55 void *p; |
56 uint8_t *pCur, *pEnd; | 56 uint8_t *pCur, *pEnd; |
57 p = (uint8_t *)pModule->JBig2_Malloc((FX_DWORD)size); | 57 p = (uint8_t *)pModule->JBig2_Malloc((FX_DWORD)size); |
58 pCur = (uint8_t *)p; | 58 pCur = (uint8_t *)p; |
59 pEnd = pCur + size; | 59 pEnd = pCur + size; |
60 for(; pCur < pEnd; pCur += unit_size) { | 60 for(; pCur < pEnd; pCur += unit_size) { |
61 ((CJBig2_Object *)pCur)->m_pModule = pModule; | 61 ((CJBig2_Object *)pCur)->m_pModule = pModule; |
62 } | 62 } |
63 return p; | 63 return p; |
64 } | 64 } |
65 void CJBig2_Object::operator delete[](void* p) | 65 void CJBig2_Object::operator delete[](void* p) |
66 { | 66 { |
67 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); | 67 ((CJBig2_Object *)p)->m_pModule->JBig2_Free(p); |
68 } | 68 } |
69 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t un
it_size) | 69 void CJBig2_Object::operator delete[](void *p, CJBig2_Module *pModule, size_t un
it_size) |
70 { | 70 { |
71 pModule->JBig2_Free(p); | 71 pModule->JBig2_Free(p); |
72 } | 72 } |
OLD | NEW |