Index: src/OFStream.h
==================================================================
--- src/OFStream.h
+++ src/OFStream.h
@@ -21,18 +21,24 @@
@class OFDataArray;
/**
* \brief A base class for different types of streams.
+ *
+ * WARNING: Even though the OFCopying protocol is implemented, it does
+ * not return an independant copy of the stream but instead retains it.
+ * This is so that the stream can be used as a key for a dictionary so context
+ * can be associated with a stream. Using a stream in more than one thread at
+ * the same time is not thread-safe, even if copy was called!
*
* IMPORTANT: If you want to subclass this, override _readNBytes:intoBuffer:,
* _writeNBytes:fromBuffer: and _isAtEndOfStream, but nothing else. Those are
* not defined in the headers, but do the actual work. OFStream uses those and
* does all the caching and other stuff. If you override these methods without
* the _ prefix, you *WILL* break caching and get broken results!
*/
-@interface OFStream: OFObject
+@interface OFStream: OFObject
{
char *cache;
char *writeBuffer;
size_t cacheLength, writeBufferLength;
BOOL buffersWrites;
Index: src/OFStream.m
==================================================================
--- src/OFStream.m
+++ src/OFStream.m
@@ -87,10 +87,15 @@
fromBuffer: (const void*)buffer
{
@throw [OFNotImplementedException newWithClass: isa
selector: _cmd];
}
+
+- copy
+{
+ return [self retain];
+}
- (BOOL)isAtEndOfStream
{
if (cache != NULL)
return NO;