summaryrefslogtreecommitdiff
path: root/core/include/fxcrt
diff options
context:
space:
mode:
Diffstat (limited to 'core/include/fxcrt')
-rw-r--r--core/include/fxcrt/fx_basic.h133
-rw-r--r--core/include/fxcrt/fx_memory.h264
-rw-r--r--core/include/fxcrt/fx_stream.h24
-rw-r--r--core/include/fxcrt/fx_string.h28
-rw-r--r--core/include/fxcrt/fx_xml.h70
5 files changed, 113 insertions, 406 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index bdb1599491..c400a940ff 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -1,15 +1,11 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_BASIC_H_
#define _FX_BASIC_H_
-#ifndef _STDINT_H_
-#define _STDINT_H_
-#include <stdint.h>
-#endif
#ifndef _FX_SYSTEM_H_
#include "fx_system.h"
#endif
@@ -22,14 +18,11 @@
#ifndef _FX_STREAM_H_
#include "fx_stream.h"
#endif
-
class CFX_BinaryBuf : public CFX_Object
{
public:
-
- CFX_BinaryBuf(IFX_Allocator* pAllocator = NULL);
-
- CFX_BinaryBuf(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
+ CFX_BinaryBuf();
+ CFX_BinaryBuf(FX_STRSIZE size);
~CFX_BinaryBuf();
@@ -75,11 +68,8 @@ public:
}
CFX_ByteStringC GetByteString() const;
- void GetByteStringL(CFX_ByteStringL &str) const;
void DetachBuffer();
-
- IFX_Allocator* m_pAllocator;
protected:
FX_STRSIZE m_AllocStep;
@@ -96,8 +86,6 @@ class CFX_ByteTextBuf : public CFX_BinaryBuf
{
public:
- CFX_ByteTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
-
void operator = (FX_BSTR str);
void AppendChar(int ch)
@@ -124,8 +112,6 @@ class CFX_WideTextBuf : public CFX_BinaryBuf
{
public:
- CFX_WideTextBuf(IFX_Allocator* pAllocator = NULL) : CFX_BinaryBuf(pAllocator) {}
-
void operator = (FX_LPCWSTR lpsz);
void operator = (FX_WSTR str);
@@ -159,13 +145,11 @@ public:
}
CFX_WideStringC GetWideString() const;
- void GetWideStringL(CFX_WideStringL& wideText) const;
};
class CFX_ArchiveSaver : public CFX_Object
{
public:
-
- CFX_ArchiveSaver(IFX_Allocator* pAllocator = NULL) : m_SavingBuf(pAllocator), m_pStream(NULL) {}
+ CFX_ArchiveSaver() : m_pStream(NULL) {}
CFX_ArchiveSaver& operator << (FX_BYTE i);
@@ -239,8 +223,7 @@ protected:
class IFX_BufferArchive
{
public:
-
- IFX_BufferArchive(FX_STRSIZE size, IFX_Allocator* pAllocator = NULL);
+ IFX_BufferArchive(FX_STRSIZE size);
virtual void Clear();
@@ -262,9 +245,6 @@ protected:
virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
-
- IFX_Allocator* m_pAllocator;
-
FX_STRSIZE m_BufSize;
FX_LPBYTE m_pBuffer;
@@ -274,7 +254,7 @@ protected:
class CFX_FileBufferArchive : public IFX_BufferArchive, public CFX_Object
{
public:
- CFX_FileBufferArchive(FX_STRSIZE size = 32768, IFX_Allocator* pAllocator = NULL);
+ CFX_FileBufferArchive(FX_STRSIZE size = 32768);
~CFX_FileBufferArchive();
virtual void Clear();
@@ -305,8 +285,7 @@ struct CFX_CharMap {
class CFX_UTF8Decoder
{
public:
-
- CFX_UTF8Decoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
+ CFX_UTF8Decoder()
{
m_PendingBytes = 0;
}
@@ -326,10 +305,6 @@ public:
{
return m_Buffer.GetWideString();
}
- void GetResult(CFX_WideStringL &result) const
- {
- m_Buffer.GetWideStringL(result);
- }
protected:
int m_PendingBytes;
@@ -341,8 +316,7 @@ protected:
class CFX_UTF8Encoder
{
public:
-
- CFX_UTF8Encoder(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator)
+ CFX_UTF8Encoder()
{
m_UTF16First = 0;
}
@@ -359,10 +333,6 @@ public:
{
return m_Buffer.GetByteString();
}
- void GetResult(CFX_ByteStringL &result) const
- {
- m_Buffer.GetByteStringL(result);
- }
protected:
CFX_ByteTextBuf m_Buffer;
@@ -375,12 +345,8 @@ CFX_ByteString FX_EncodeURI(const CFX_WideString& wsURI);
CFX_WideString FX_DecodeURI(const CFX_ByteString& bsURI);
class CFX_BasicArray : public CFX_Object
{
-public:
-
- IFX_Allocator* m_pAllocator;
protected:
-
- CFX_BasicArray(int unit_size, IFX_Allocator* pAllocator = NULL);
+ CFX_BasicArray(int unit_size);
~CFX_BasicArray();
@@ -413,8 +379,7 @@ template<class TYPE>
class CFX_ArrayTemplate : public CFX_BasicArray
{
public:
-
- CFX_ArrayTemplate(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(TYPE), pAllocator) {}
+ CFX_ArrayTemplate() : CFX_BasicArray(sizeof(TYPE)) {}
int GetSize() const
{
@@ -580,8 +545,7 @@ template <class ObjectClass>
class CFX_ObjectArray : public CFX_BasicArray
{
public:
-
- CFX_ObjectArray(IFX_Allocator* pAllocator = NULL) : CFX_BasicArray(sizeof(ObjectClass), pAllocator) {}
+ CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {}
~CFX_ObjectArray()
{
@@ -697,8 +661,7 @@ typedef CFX_ObjectArray<CFX_WideString> CFX_WideStringArray;
class CFX_BaseSegmentedArray : public CFX_Object
{
public:
-
- CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8, IFX_Allocator* pAllocator = NULL);
+ CFX_BaseSegmentedArray(int unit_size = 1, int segment_units = 512, int index_size = 8);
~CFX_BaseSegmentedArray();
@@ -728,8 +691,6 @@ public:
}
void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const;
-
- IFX_Allocator* m_pAllocator;
private:
int m_UnitSize;
@@ -751,9 +712,8 @@ template <class ElementType>
class CFX_SegmentedArray : public CFX_BaseSegmentedArray
{
public:
-
- CFX_SegmentedArray(int segment_units, int index_size = 8, IFX_Allocator* pAllocator = NULL)
- : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size, pAllocator)
+ CFX_SegmentedArray(int segment_units, int index_size = 8)
+ : CFX_BaseSegmentedArray(sizeof(ElementType), segment_units, index_size)
{}
void Add(ElementType data)
@@ -770,43 +730,32 @@ template <class DataType, int FixedSize>
class CFX_FixedBufGrow : public CFX_Object
{
public:
- CFX_FixedBufGrow(IFX_Allocator* pAllocator = NULL)
- : m_pAllocator(pAllocator)
- , m_pData(NULL)
+ CFX_FixedBufGrow() : m_pData(NULL)
{}
- CFX_FixedBufGrow(int data_size, IFX_Allocator* pAllocator = NULL)
- : m_pAllocator(pAllocator)
- , m_pData(NULL)
+ CFX_FixedBufGrow(int data_size) : m_pData(NULL)
{
if (data_size > FixedSize) {
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
+ m_pData = FX_Alloc(DataType, data_size);
} else {
- if (FixedSize > SIZE_MAX/sizeof(DataType))
- return;
-
FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
}
}
void SetDataSize(int data_size)
{
if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
+ FX_Free(m_pData);
}
m_pData = NULL;
if (data_size > FixedSize) {
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, data_size);
+ m_pData = FX_Alloc(DataType, data_size);
} else {
-
- if (FixedSize > SIZE_MAX/sizeof(DataType))
- return;
-
FXSYS_memset32(m_Data, 0, sizeof(DataType)*FixedSize);
}
}
~CFX_FixedBufGrow()
{
if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
+ FX_Free(m_pData);
}
}
operator DataType*()
@@ -814,7 +763,6 @@ public:
return m_pData ? m_pData : m_Data;
}
private:
- IFX_Allocator* m_pAllocator;
DataType m_Data[FixedSize];
DataType* m_pData;
};
@@ -822,14 +770,14 @@ template <class DataType>
class CFX_TempBuf
{
public:
- CFX_TempBuf(int size, IFX_Allocator* pAllocator = NULL) : m_pAllocator(pAllocator)
+ CFX_TempBuf(int size)
{
- m_pData = FX_Allocator_Alloc(m_pAllocator, DataType, size);
+ m_pData = FX_Alloc(DataType, size);
}
~CFX_TempBuf()
{
if (m_pData) {
- FX_Allocator_Free(m_pAllocator, m_pData);
+ FX_Free(m_pData);
}
}
DataType& operator[](int i)
@@ -842,7 +790,6 @@ public:
return m_pData;
}
private:
- IFX_Allocator* m_pAllocator;
DataType* m_pData;
};
class CFX_MapPtrToPtr : public CFX_Object
@@ -858,8 +805,7 @@ protected:
void* value;
};
public:
-
- CFX_MapPtrToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+ CFX_MapPtrToPtr(int nBlockSize = 10);
~CFX_MapPtrToPtr();
@@ -903,8 +849,6 @@ public:
void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE);
protected:
- IFX_Allocator* m_pAllocator;
-
CAssoc** m_pHashTable;
FX_DWORD m_nHashTableSize;
@@ -929,8 +873,7 @@ template <class KeyType, class ValueType>
class CFX_MapPtrTemplate : public CFX_MapPtrToPtr
{
public:
-
- CFX_MapPtrTemplate(IFX_Allocator* pAllocator = NULL) : CFX_MapPtrToPtr(10, pAllocator) {}
+ CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {}
FX_BOOL Lookup(KeyType key, ValueType& rValue) const
{
@@ -970,8 +913,6 @@ class CFX_CMapDWordToDWord : public CFX_Object
{
public:
- CFX_CMapDWordToDWord(IFX_Allocator* pAllocator = NULL) : m_Buffer(pAllocator) {}
-
FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
void SetAt(FX_DWORD key, FX_DWORD value);
@@ -1000,8 +941,7 @@ protected:
void* value;
};
public:
-
- CFX_MapByteStringToPtr(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+ CFX_MapByteStringToPtr(int nBlockSize = 10);
int GetCount() const
{
@@ -1045,8 +985,6 @@ public:
FX_DWORD HashKey(FX_BSTR key) const;
protected:
- IFX_Allocator* m_pAllocator;
-
CAssoc** m_pHashTable;
FX_DWORD m_nHashTableSize;
@@ -1071,8 +1009,7 @@ public:
class CFX_CMapByteStringToPtr : public CFX_Object
{
public:
-
- CFX_CMapByteStringToPtr(IFX_Allocator* pAllocator = NULL);
+ CFX_CMapByteStringToPtr();
~CFX_CMapByteStringToPtr();
@@ -1110,8 +1047,7 @@ protected:
void* data;
};
public:
-
- CFX_PtrList(int nBlockSize = 10, IFX_Allocator* pAllocator = NULL);
+ CFX_PtrList(int nBlockSize = 10);
FX_POSITION GetHeadPosition() const
{
@@ -1179,8 +1115,6 @@ public:
void RemoveAll();
protected:
- IFX_Allocator* m_pAllocator;
-
CNode* m_pNodeHead;
CNode* m_pNodeTail;
@@ -1217,8 +1151,6 @@ class CFX_PrivateData
{
public:
- CFX_PrivateData(IFX_Allocator* pAllocator = NULL) : m_DataList(pAllocator) {}
-
~CFX_PrivateData();
void ClearAll();
@@ -1507,7 +1439,7 @@ protected:
};
public:
- CFX_SortListArray(IFX_Allocator* pAllocator = NULL) : m_CurList(0), m_DataLists(pAllocator) {}
+ CFX_SortListArray() : m_CurList(0) {}
~CFX_SortListArray()
{
@@ -1517,11 +1449,10 @@ public:
void Clear()
{
- IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) {
DataList list = m_DataLists.ElementAt(i);
if (list.data) {
- FX_Allocator_Free(pAllocator, list.data);
+ FX_Free(list.data);
}
}
m_DataLists.RemoveAll();
@@ -1533,15 +1464,13 @@ public:
if (nStart < 0) {
return;
}
- IFX_Allocator* pAllocator = m_DataLists.m_pAllocator;
while (nCount > 0) {
FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
DataList list;
- list.data = FX_Allocator_Alloc(pAllocator, FX_BYTE, temp_count * unit);
+ list.data = FX_Alloc(FX_BYTE, temp_count * unit);
if (!list.data) {
break;
}
- FXSYS_memset32(list.data, 0, temp_count * unit);
list.start = nStart;
list.count = temp_count;
Append(list);
diff --git a/core/include/fxcrt/fx_memory.h b/core/include/fxcrt/fx_memory.h
index 1869ccc0e8..cb71c04fca 100644
--- a/core/include/fxcrt/fx_memory.h
+++ b/core/include/fxcrt/fx_memory.h
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_MEMORY_H_
@@ -9,91 +9,70 @@
#ifndef _FX_SYSTEM_H_
#include "fx_system.h"
#endif
-#define FXMEM_NONLEAVE 1
-#define FXMEM_MOVABLE 2
-#define FXMEM_DISCARDABLE 4
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct _FXMEM_SystemMgr {
-
- void* (*Alloc)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags);
-
- void* (*AllocDebug)(struct _FXMEM_SystemMgr* pMgr, size_t size, int flags, FX_LPCSTR file, int line);
-
- void* (*Realloc)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags);
-
- void* (*ReallocDebug)(struct _FXMEM_SystemMgr* pMgr, void* pointer, size_t size, int flags, FX_LPCSTR file, int line);
-
- void* (*Lock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
-
- void (*Unlock)(struct _FXMEM_SystemMgr* pMgr, void* handle);
-
- void (*Free)(struct _FXMEM_SystemMgr* pMgr, void* pointer, int flags);
-
- void (*Purge)(struct _FXMEM_SystemMgr* pMgr);
-
- void (*CollectAll)(struct _FXMEM_SystemMgr* pMgr);
-
-
- void* user;
-} FXMEM_SystemMgr;
-FX_DEFINEHANDLE(FXMEM_FoxitMgr)
-typedef struct _FXMEM_SystemMgr2 {
-
- FX_BOOL (*More)(struct _FXMEM_SystemMgr2* pMgr, size_t alloc_size, void** new_memory, size_t* new_size);
-
- void (*Free)(struct _FXMEM_SystemMgr2* pMgr, void* memory);
-} FXMEM_SystemMgr2;
-FXMEM_FoxitMgr* FXMEM_CreateMemoryMgr(size_t size, FX_BOOL extensible);
-void FXMEM_DestroyFoxitMgr(FXMEM_FoxitMgr* pFoxitMgr);
+#define FX_Alloc(type, size) (type*)calloc(size, sizeof(type))
+#define FX_Realloc(type, ptr, size) (type*)realloc(ptr, sizeof(type) * (size))
+#define FX_AllocNL(type, size) FX_Alloc(type, size)
+#define FX_ReallocNL(type, ptr, size) FX_Realloc(type, ptr, size)
+#define FX_Free(ptr) free(ptr)
void* FXMEM_DefaultAlloc(size_t byte_size, int flags);
-void* FXMEM_DefaultAlloc2(size_t units, size_t unit_size, int flags);
void* FXMEM_DefaultRealloc(void* pointer, size_t new_size, int flags);
-void* FXMEM_DefaultRealloc2(void* pointer, size_t units, size_t unit_size, int flags);
void FXMEM_DefaultFree(void* pointer, int flags);
-#define FX_Alloc(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), 0)
-#define FX_Realloc(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), 0)
-#define FX_AllocNL(type, size) (type*)FXMEM_DefaultAlloc2(size, sizeof(type), FXMEM_NONLEAVE)
-#define FX_ReallocNL(type, ptr, size) (type*)FXMEM_DefaultRealloc2(ptr, size, sizeof(type), FXMEM_NONLEAVE)
-#define FX_Free(pointer) FXMEM_DefaultFree(pointer, 0)
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
-#if defined(_DEBUG)
-#define FX_NEW new(__FILE__, __LINE__)
-#else
-
-#define FX_NEW new
-#endif
class CFX_Object
{
public:
-
- void* operator new (size_t size, FX_LPCSTR file, int line);
-
- void operator delete (void* p, FX_LPCSTR file, int line);
-
- void* operator new (size_t size);
-
- void operator delete (void* p);
-
- void* operator new[] (size_t size, FX_LPCSTR file, int line);
-
- void operator delete[] (void* p, FX_LPCSTR file, int line);
-
- void* operator new[] (size_t size);
-
- void operator delete[] (void* p);
-
+ void* operator new (size_t size, FX_LPCSTR file, int line)
+ {
+ return malloc(size);
+ }
+ void operator delete (void* p, FX_LPCSTR file, int line)
+ {
+ free(p);
+ }
+ void* operator new (size_t size)
+ {
+ return malloc(size);
+ }
+ void operator delete (void* p)
+ {
+ free(p);
+ }
+ void* operator new[] (size_t size, FX_LPCSTR file, int line)
+ {
+ return malloc(size);
+ }
+ void operator delete[] (void* p, FX_LPCSTR file, int line)
+ {
+ free(p);
+ }
+ void* operator new[] (size_t size)
+ {
+ return malloc(size);
+ }
+ void operator delete[] (void* p)
+ {
+ free(p);
+ }
void* operator new (size_t, void* buf)
{
return buf;
}
-
- void operator delete (void*, void*) {}
+ void operator delete (void*, void*) {}
};
+#endif
+#ifdef __cplusplus
+#if defined(_DEBUG)
+#define FX_NEW new(__FILE__, __LINE__)
+#else
+
+#define FX_NEW new
+#endif
#define FX_NEW_VECTOR(Pointer, Class, Count) \
{ \
Pointer = FX_Alloc(Class, Count); \
@@ -112,126 +91,14 @@ public:
virtual ~CFX_DestructObject() {}
};
-#ifdef __cplusplus
-extern "C" {
-#endif
-typedef struct _IFX_Allocator {
-
- void* (*m_AllocDebug)(struct _IFX_Allocator* pAllocator, size_t num, size_t size, FX_LPCSTR file, int line);
-
- void* (*m_Alloc)(struct _IFX_Allocator* pAllocator, size_t num, size_t size);
-
- void* (*m_ReallocDebug)(struct _IFX_Allocator* pAllocator, void* p, size_t num, size_t size, FX_LPCSTR file, int line);
-
- void* (*m_Realloc)(struct _IFX_Allocator* pAllocator, void* p, size_t num, size_t size);
-
- void (*m_Free)(struct _IFX_Allocator* pAllocator, void* p);
-} IFX_Allocator;
-IFX_Allocator* FXMEM_GetDefAllocator();
-#ifdef __cplusplus
-}
-#endif
-#ifdef _DEBUG
-
-#define FX_Allocator_Alloc(fxAllocator, type, size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_AllocDebug((fxAllocator), (size), sizeof(type), __FILE__, __LINE__) : (FX_Alloc(type, size)))
-
-#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_ReallocDebug((fxAllocator), (ptr), (new_size) , sizeof(type), __FILE__, __LINE__) : (FX_Realloc(type, ptr, new_size)))
-#else
-
-#define FX_Allocator_Alloc(fxAllocator, type, size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_Alloc((fxAllocator), (size), sizeof(type)) : (FX_Alloc(type, size)))
-
-#define FX_Allocator_Realloc(fxAllocator, type, ptr, new_size) \
- ((fxAllocator) ? (type*)(fxAllocator)->m_Realloc((fxAllocator), (ptr), (new_size), sizeof(type)) : (FX_Realloc(type, ptr, new_size)))
-#endif
-#define FX_Allocator_Free(fxAllocator, ptr) \
- ((fxAllocator) ? (fxAllocator)->m_Free((fxAllocator), (ptr)) : (FX_Free(ptr)))
-inline void* operator new(size_t size, IFX_Allocator* fxAllocator)
-{
- return (void*)FX_Allocator_Alloc(fxAllocator, FX_BYTE, size);
-}
-inline void operator delete(void* ptr, IFX_Allocator* fxAllocator)
-{
-}
-#define FX_NewAtAllocator(fxAllocator) \
- ::new(fxAllocator)
-#define FX_DeleteAtAllocator(pointer, fxAllocator, __class__) \
- (pointer)->~__class__(); \
- FX_Allocator_Free(fxAllocator, pointer)
-class CFX_AllocObject
-{
-public:
-
- void* operator new (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line);
-#endif
-
- void* operator new (size_t size, IFX_Allocator* pAllocator);
-
- void operator delete (void* p);
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void* p, IFX_Allocator* pAllocator);
-#endif
-
- void* operator new (size_t, void* buf)
- {
- return buf;
- }
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete (void*, void*) {}
-#endif
-
- IFX_Allocator* GetAllocator() const
- {
- return m_pAllocator;
- }
-private:
-
- void* operator new[] (size_t size, IFX_Allocator* pAllocator, FX_LPCSTR file, int line)
- {
- return operator new(size, pAllocator, file, line);
- }
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete[] (void* p, IFX_Allocator* pAllocator, FX_LPCSTR file, int line) {}
-#endif
-
- void* operator new[] (size_t size, IFX_Allocator* pAllocator)
- {
- return operator new(size, pAllocator);
- }
-
- void operator delete[] (void* p) {}
-#ifndef _FX_NO_EXCEPTION_
-
- void operator delete[] (void* p, IFX_Allocator* pAllocator) {}
-#endif
-protected:
-
- IFX_Allocator* m_pAllocator;
-};
-#if defined(_DEBUG)
-#define FX_NEWAT(pAllocator) new(pAllocator, __FILE__, __LINE__)
-#else
-
-#define FX_NEWAT(pAllocator) new(pAllocator)
-#endif
-class CFX_GrowOnlyPool : public IFX_Allocator, public CFX_Object
+class CFX_GrowOnlyPool : public CFX_Object
{
public:
- CFX_GrowOnlyPool(IFX_Allocator* pAllocator = NULL, size_t trunk_size = 16384);
+ CFX_GrowOnlyPool(size_t trunk_size = 16384);
~CFX_GrowOnlyPool();
- void SetAllocator(IFX_Allocator* pAllocator);
-
void SetTrunkSize(size_t trunk_size)
{
m_TrunkSize = trunk_size;
@@ -262,39 +129,6 @@ private:
size_t m_TrunkSize;
void* m_pFirstTrunk;
-
- IFX_Allocator* m_pAllocator;
};
#endif
-#ifdef __cplusplus
-extern "C" {
-#endif
-#define FX_FIXEDMEM_PAGESIZE (4096 * 16)
-#define FX_FIXEDMEM_MIDBLOCKSIZE (4096)
-typedef struct _FX_MEMCONFIG {
-
- size_t nPageNum_Init8;
-
- size_t nPageNum_Init16;
-
- size_t nPageNum_Init32;
-
- size_t nPageNum_More16;
-
- size_t nPageNum_More32;
-
- size_t nPageSize_Mid;
-
- size_t nPageNum_InitMid;
-
- size_t nPageNum_MoreMid;
-
- size_t nPageSize_Large;
-
- size_t nPageSize_Alone;
-} FX_MEMCONFIG;
-void FXMEM_SetConfig(const FX_MEMCONFIG* memConfig);
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h
index 869797f7e9..ef730bb967 100644
--- a/core/include/fxcrt/fx_stream.h
+++ b/core/include/fxcrt/fx_stream.h
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_STREAM_H_
@@ -41,9 +41,9 @@ FX_DEFINEHANDLE(FX_HFILE)
#define FX_FILEMODE_Write 0
#define FX_FILEMODE_ReadOnly 1
#define FX_FILEMODE_Truncate 2
-FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode, IFX_Allocator* pAllocator = NULL);
-void FX_File_Close(FX_HFILE hFile, IFX_Allocator* pAllocator = NULL);
+FX_HFILE FX_File_Open(FX_BSTR fileName, FX_DWORD dwMode);
+FX_HFILE FX_File_Open(FX_WSTR fileName, FX_DWORD dwMode);
+void FX_File_Close(FX_HFILE hFile);
FX_FILESIZE FX_File_GetSize(FX_HFILE hFile);
FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile);
FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos);
@@ -85,8 +85,8 @@ public:
return WriteBlock(pData, GetSize(), size);
}
};
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCSTR filename);
+IFX_FileWrite* FX_CreateFileWrite(FX_LPCWSTR filename);
class IFX_StreamRead
{
public:
@@ -131,8 +131,8 @@ public:
return 0;
}
};
-IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename, IFX_Allocator* pAllocator = NULL);
-IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename, IFX_Allocator* pAllocator = NULL);
+IFX_FileRead* FX_CreateFileRead(FX_LPCSTR filename);
+IFX_FileRead* FX_CreateFileRead(FX_LPCWSTR filename);
class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite
{
public:
@@ -159,8 +159,8 @@ public:
virtual FX_BOOL Flush() = 0;
};
-IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
-IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes, IFX_Allocator* pAllocator = NULL);
+IFX_FileStream* FX_CreateFileStream(FX_LPCSTR filename, FX_DWORD dwModes);
+IFX_FileStream* FX_CreateFileStream(FX_LPCWSTR filename, FX_DWORD dwModes);
class IFX_MemoryStream : public IFX_FileStream
{
public:
@@ -175,8 +175,8 @@ public:
virtual void DetachBuffer() = 0;
};
-IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE, IFX_Allocator* pAllocator = NULL);
-IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE, IFX_Allocator* pAllocator = NULL);
+IFX_MemoryStream* FX_CreateMemoryStream(FX_LPBYTE pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE);
+IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
class IFX_BufferRead : public IFX_StreamRead
{
public:
diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h
index 7e02101def..fe56e1867e 100644
--- a/core/include/fxcrt/fx_string.h
+++ b/core/include/fxcrt/fx_string.h
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_STRING_H_
@@ -841,30 +841,4 @@ inline CFX_ByteString FX_UTF8Encode(const CFX_WideString &wsStr)
{
return FX_UTF8Encode((FX_LPCWSTR)wsStr, wsStr.GetLength());
}
-class CFX_ByteStringL : public CFX_ByteStringC
-{
-public:
- CFX_ByteStringL() : CFX_ByteStringC() {}
- ~CFX_ByteStringL() {}
-
- void Empty(IFX_Allocator* pAllocator);
- FX_LPSTR AllocBuffer(FX_STRSIZE length, IFX_Allocator* pAllocator);
-
- void Set(FX_BSTR src, IFX_Allocator* pAllocator);
-};
-class CFX_WideStringL : public CFX_WideStringC
-{
-public:
- CFX_WideStringL() : CFX_WideStringC() {}
- ~CFX_WideStringL() {}
-
- void Empty(IFX_Allocator* pAllocator);
- void Set(FX_WSTR src, IFX_Allocator* pAllocator);
-
- int GetInteger() const;
- FX_FLOAT GetFloat() const;
-
- void TrimRight(FX_LPCWSTR lpszTargets);
-};
-void FX_UTF8Encode(FX_LPCWSTR pwsStr, FX_STRSIZE len, CFX_ByteStringL &utf8Str, IFX_Allocator* pAllocator = NULL);
#endif
diff --git a/core/include/fxcrt/fx_xml.h b/core/include/fxcrt/fx_xml.h
index 19a49cde12..fb46a93591 100644
--- a/core/include/fxcrt/fx_xml.h
+++ b/core/include/fxcrt/fx_xml.h
@@ -1,7 +1,7 @@
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-
+
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef _FX_XML_H_
@@ -12,16 +12,9 @@
class CXML_AttrItem : public CFX_Object
{
public:
- CFX_ByteStringL m_QSpaceName;
- CFX_ByteStringL m_AttrName;
- CFX_WideStringL m_Value;
-
- void Empty(IFX_Allocator* pAllocator = NULL)
- {
- m_QSpaceName.Empty(pAllocator);
- m_AttrName.Empty(pAllocator);
- m_Value.Empty(pAllocator);
- }
+ CFX_ByteString m_QSpaceName;
+ CFX_ByteString m_AttrName;
+ CFX_WideString m_Value;
};
class CXML_AttrMap : public CFX_Object
{
@@ -32,12 +25,12 @@ public:
}
~CXML_AttrMap()
{
- RemoveAll(NULL);
+ RemoveAll();
}
- const CFX_WideStringL* Lookup(FX_BSTR space, FX_BSTR name) const;
- void SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value, IFX_Allocator* pAllocator = NULL);
- void RemoveAt(FX_BSTR space, FX_BSTR name, IFX_Allocator* pAllocator = NULL);
- void RemoveAll(IFX_Allocator* pAllocator = NULL);
+ const CFX_WideString* Lookup(FX_BSTR space, FX_BSTR name) const;
+ void SetAt(FX_BSTR space, FX_BSTR name, FX_WSTR value);
+ void RemoveAt(FX_BSTR space, FX_BSTR name);
+ void RemoveAll();
int GetSize() const;
CXML_AttrItem& GetAt(int index) const;
CFX_ObjectArray<CXML_AttrItem>* m_pMap;
@@ -46,37 +39,23 @@ class CXML_Content : public CFX_Object
{
public:
CXML_Content() : m_bCDATA(FALSE), m_Content() {}
- ~CXML_Content()
- {
- Empty(NULL);
- }
- void Empty(IFX_Allocator* pAllocator = NULL)
- {
- m_Content.Empty(pAllocator);
- }
- void Set(FX_BOOL bCDATA, FX_WSTR content, IFX_Allocator* pAllocator = NULL)
+ void Set(FX_BOOL bCDATA, FX_WSTR content)
{
m_bCDATA = bCDATA;
- m_Content.Set(content, pAllocator);
+ m_Content = content;
}
FX_BOOL m_bCDATA;
- CFX_WideStringL m_Content;
+ CFX_WideString m_Content;
};
class CXML_Element : public CFX_Object
{
public:
-
- static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(FX_BSTR qSpace, FX_BSTR tagName, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(FX_BSTR qTagName, IFX_Allocator* pAllocator = NULL);
-
- CXML_Element(IFX_Allocator* pAllocator = NULL);
+ static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+ static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+ static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL);
+ CXML_Element(FX_BSTR qSpace, FX_BSTR tagName);
+ CXML_Element(FX_BSTR qTagName);
+ CXML_Element();
~CXML_Element();
@@ -85,13 +64,10 @@ public:
CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const;
- void GetTagName(CFX_ByteStringL &tagName, FX_BOOL bQualified = FALSE) const;
CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const;
- void GetNamespace(CFX_ByteStringL &nameSpace, FX_BOOL bQualified = FALSE) const;
CFX_ByteString GetNamespaceURI(FX_BSTR qName) const;
- void GetNamespaceURI(FX_BSTR qName, CFX_ByteStringL &uri) const;
CXML_Element* GetParent() const
{
@@ -104,7 +80,6 @@ public:
}
void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const;
- void GetAttrByIndex(int index, CFX_ByteStringL &space, CFX_ByteStringL &name, CFX_WideStringL &value) const;
FX_BOOL HasAttr(FX_BSTR qName) const;
@@ -115,7 +90,6 @@ public:
GetAttrValue(name, attr);
return attr;
}
- const CFX_WideStringL* GetAttrValuePtr(FX_BSTR name) const;
FX_BOOL GetAttrValue(FX_BSTR space, FX_BSTR name, CFX_WideString& attribute) const;
CFX_WideString GetAttrValue(FX_BSTR space, FX_BSTR name) const
@@ -124,7 +98,6 @@ public:
GetAttrValue(space, name, attr);
return attr;
}
- const CFX_WideStringL* GetAttrValuePtr(FX_BSTR space, FX_BSTR name) const;
FX_BOOL GetAttrInteger(FX_BSTR name, int& attribute) const;
int GetAttrInteger(FX_BSTR name) const
@@ -165,7 +138,6 @@ public:
ChildType GetChildType(FX_DWORD index) const;
CFX_WideString GetContent(FX_DWORD index) const;
- const CFX_WideStringL* GetContentPtr(FX_DWORD index) const;
CXML_Element* GetElement(FX_DWORD index) const;
@@ -195,10 +167,8 @@ public:
protected:
CXML_Element* m_pParent;
-
- CFX_ByteStringL m_QSpaceName;
-
- CFX_ByteStringL m_TagName;
+ CFX_ByteString m_QSpaceName;
+ CFX_ByteString m_TagName;
CXML_AttrMap m_AttrMap;