blob: 589e8b59c06db818a18d7c3ee85a1fdedbfa17cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
//
// MCDataMac.m
// mailcore2
//
// Created by Hoa V. DINH on 10/24/14.
// Copyright (c) 2014 MailCore. All rights reserved.
//
#include "MCData.h"
#import <Foundation/Foundation.h>
using namespace mailcore;
CFDataRef Data::destructiveNSData()
{
NSData * result;
if (mExternallyAllocatedMemory) {
BytesDeallocator deallocator = mBytesDeallocator;
result = [[[NSData alloc] initWithBytesNoCopy:mBytes length:mLength deallocator:^(void * bytes, NSUInteger length) {
if (deallocator) {
deallocator((char *)bytes, (unsigned int)length);
}
}] autorelease];
} else {
result = [NSData dataWithBytesNoCopy:(void *) mBytes length:mLength];
}
init();
return (CFDataRef) result;
}
|