THRIFT-821. Add a method to get a copy of the TMemoryBuffer's buffer.
authorAndrew McGeachie <geechorama@apache.org>
Wed, 21 Jul 2010 19:51:04 +0000 (19:51 +0000)
committerAndrew McGeachie <geechorama@apache.org>
Wed, 21 Jul 2010 19:51:04 +0000 (19:51 +0000)
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@966385 13f79535-47bb-0310-9956-ffa450edef68

lib/cocoa/src/transport/TMemoryBuffer.h
lib/cocoa/src/transport/TMemoryBuffer.m

index 45a5e17..fa4d371 100644 (file)
@@ -25,4 +25,5 @@
        NSUInteger mOffset;
 }
 - (id)initWithData:(NSData *)data;
+- (NSData *)getBuffer;
 @end
index 7912bcd..869010a 100644 (file)
 #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];
        // noop
 }
 
+- (NSData *)getBuffer {
+       return [[mBuffer copy] autorelease];
+}
+
 - (void)dealloc {
        [mBuffer release];
        [super dealloc];