Small optimization, we avoid copying potentially big array of bytes by attaching a wrapper around the NSData object to the resulting binary structure
parent
a549773554
commit
2758b44d37
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#import <NGExtensions/NSObject+Logs.h>
|
#import <NGExtensions/NSObject+Logs.h>
|
||||||
|
|
||||||
|
#import "NSObject+MAPIStore.h"
|
||||||
#import "NSString+MAPIStore.h"
|
#import "NSString+MAPIStore.h"
|
||||||
|
|
||||||
#import "NSData+MAPIStore.h"
|
#import "NSData+MAPIStore.h"
|
||||||
|
@ -42,13 +43,11 @@
|
||||||
- (struct Binary_r *) asBinaryInMemCtx: (void *) memCtx
|
- (struct Binary_r *) asBinaryInMemCtx: (void *) memCtx
|
||||||
{
|
{
|
||||||
struct Binary_r *binary;
|
struct Binary_r *binary;
|
||||||
uint8_t *lpb;
|
|
||||||
|
|
||||||
binary = talloc_zero (memCtx, struct Binary_r);
|
binary = talloc_zero (memCtx, struct Binary_r);
|
||||||
binary->cb = [self length];
|
binary->cb = [self length];
|
||||||
lpb = talloc_array (binary, uint8_t, binary->cb);
|
binary->lpb = (uint8_t *) [self bytes];
|
||||||
[self getBytes: lpb];
|
[self tallocWrapper: binary];
|
||||||
binary->lpb = lpb;
|
|
||||||
|
|
||||||
return binary;
|
return binary;
|
||||||
}
|
}
|
||||||
|
@ -61,13 +60,11 @@
|
||||||
- (struct SBinary_short *) asShortBinaryInMemCtx: (void *) memCtx
|
- (struct SBinary_short *) asShortBinaryInMemCtx: (void *) memCtx
|
||||||
{
|
{
|
||||||
struct SBinary_short *binary;
|
struct SBinary_short *binary;
|
||||||
uint8_t *lpb;
|
|
||||||
|
|
||||||
binary = talloc_zero (memCtx, struct SBinary_short);
|
binary = talloc_zero (memCtx, struct SBinary_short);
|
||||||
binary->cb = [self length];
|
binary->cb = [self length];
|
||||||
lpb = talloc_array (binary, uint8_t, binary->cb);
|
binary->lpb = (uint8_t *) [self bytes];
|
||||||
[self getBytes: lpb];
|
[self tallocWrapper: binary];
|
||||||
binary->lpb = lpb;
|
|
||||||
|
|
||||||
return binary;
|
return binary;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue