From 43026e6c131595a23958390feaf7c587da7582aa Mon Sep 17 00:00:00 2001 From: Ferdinand Majerech Date: Tue, 22 Jul 2014 01:03:19 +0200 Subject: [PATCH] Fixed a recent commit. --- source/dyaml/reader.d | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/source/dyaml/reader.d b/source/dyaml/reader.d index a4a2ae5..b73af4c 100644 --- a/source/dyaml/reader.d +++ b/source/dyaml/reader.d @@ -44,39 +44,7 @@ package: // OR MULTIPLE VARS - USE std.format! -// XXX XXX XXX START COMMITTING STUFF HERE -/+5: /// Description+/ -ubyte[] streamToBytesGC(Stream stream) @trusted -{ - ubyte[] storage = new ubyte[stream.available]; - return stream.streamToBytes(storage); -} -/+5: /// Description+/ -/// -/// Params: -/// -/// stream = -/// memory = Memory to use. Must be long enough to store the entire stream -/// (memory.length >= stream.available). -/// -/// Returns: A slice of memory containing all contents of the stream on success. -/// NULL if unable to read the entire stream. -ubyte[] streamToBytes(Stream stream, ubyte[] memory) @system -{ - assert(memory.length >= stream.available, "Not enough memory passed to streamToBytes"); - auto buffer = memory[0 .. stream.available]; - size_t bytesRead = 0; - for(; bytesRead < buffer.length;) - { - // Returns 0 on eof - const bytes = stream.readBlock(&buffer[bytesRead], buffer.length - bytesRead); - // Reached EOF before reading buffer.length bytes. - if(bytes == 0) { return null; } - bytesRead += bytes; - } - return buffer; -} @@ -132,7 +100,7 @@ final class Reader @trusted nothrow @nogc ~this() { - //Delete the buffer, if allocated. + // Delete the buffer, if allocated. if(bufferAllocated_ is null){return;} free(bufferAllocated_.ptr); buffer_ = bufferAllocated_ = null;