mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-821. Add a method to get a copy of the TMemoryBuffer's buffer.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@966385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
da50d55232
commit
c892ac555e
@ -25,4 +25,5 @@
|
||||
NSUInteger mOffset;
|
||||
}
|
||||
- (id)initWithData:(NSData *)data;
|
||||
- (NSData *)getBuffer;
|
||||
@end
|
||||
|
@ -23,6 +23,14 @@
|
||||
#define GARBAGE_BUFFER_SIZE 4096 // 4KiB
|
||||
|
||||
@implementation TMemoryBuffer
|
||||
- (id)init {
|
||||
if (self = [super init]) {
|
||||
mBuffer = [[NSMutableData alloc] init];
|
||||
mOffset = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithData:(NSData *)data {
|
||||
if (self = [super init]) {
|
||||
mBuffer = [data mutableCopy];
|
||||
@ -52,6 +60,10 @@
|
||||
// noop
|
||||
}
|
||||
|
||||
- (NSData *)getBuffer {
|
||||
return [[mBuffer copy] autorelease];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[mBuffer release];
|
||||
[super dealloc];
|
||||
|
Loading…
Reference in New Issue
Block a user