aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/basetypes/MCData.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/basetypes/MCData.h')
-rw-r--r--src/core/basetypes/MCData.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/core/basetypes/MCData.h b/src/core/basetypes/MCData.h
index 0bb1bc07..4151757e 100644
--- a/src/core/basetypes/MCData.h
+++ b/src/core/basetypes/MCData.h
@@ -16,7 +16,9 @@
namespace mailcore {
class String;
-
+
+ typedef void (*BytesDeallocator)(char * bytes, unsigned int length);
+
class MAILCORE_EXPORT Data : public Object {
public:
Data();
@@ -49,6 +51,13 @@ namespace mailcore {
public: // private
virtual String * charsetWithFilteredHTML(bool filterHTML, String * hintCharset = NULL);
+
+ /* Replace contents of Data instance with contents of a given bytes without extra copying.
+ Memory ownership transferred from client code to the Data instance.
+ Data destructor will call bytesDeallocator function for memory releasing.
+ */
+ void takeBytesOwnership(char * bytes, unsigned int length, BytesDeallocator bytesDeallocator);
+
#ifdef __APPLE__
virtual CFDataRef destructiveNSData();
#endif
@@ -66,7 +75,10 @@ namespace mailcore {
char * mBytes;
unsigned int mLength;
unsigned int mAllocated;
+ bool mExternallyAllocatedMemory;
+ BytesDeallocator mBytesDeallocator;
void allocate(unsigned int length, bool force = false);
+ void init();
void reset();
String * charsetWithFilteredHTMLWithoutHint(bool filterHTML);
void takeBytesOwnership(char * bytes, unsigned int length);