Explorar o código

allow to change sender of a Writer without reallocation of the buffer

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7973 8c9fc860-2736-0410-a75d-ab315db34111
eth.morozova %!s(int64=7) %!d(string=hai) anos
pai
achega
7fee06370a
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      source/Streams.Mod

+ 4 - 1
source/Streams.Mod

@@ -59,7 +59,10 @@ TYPE
 		PROCEDURE & InitWriter*( send: Sender;  size: LONGINT );
 		BEGIN
 			ASSERT ( send # NIL );
-			NEW( buf, size );  SELF.send := send;  Reset
+			IF (buf = NIL) OR (LEN(buf) # size) THEN
+				NEW( buf, size );
+			END;
+			SELF.send := send;  Reset
 		END InitWriter;
 
 		PROCEDURE Reset*;