Author: geechorama
Date: Wed Jul 21 19:51:04 2010
New Revision: 966385

URL: http://svn.apache.org/viewvc?rev=966385&view=rev
Log:
THRIFT-821.  Add a method to get a copy of the TMemoryBuffer's buffer.

Modified:
    incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.h
    incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.m

Modified: incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.h
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.h?rev=966385&r1=966384&r2=966385&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.h (original)
+++ incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.h Wed Jul 21 
19:51:04 2010
@@ -25,4 +25,5 @@
        NSUInteger mOffset;
 }
 - (id)initWithData:(NSData *)data;
+- (NSData *)getBuffer;
 @end

Modified: incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.m
URL: 
http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.m?rev=966385&r1=966384&r2=966385&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.m (original)
+++ incubator/thrift/trunk/lib/cocoa/src/transport/TMemoryBuffer.m Wed Jul 21 
19:51:04 2010
@@ -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];


Reply via email to