X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fmemory-stream.cc;h=511657f5fcc733d2b15d2846155f10cbdd88477f;hb=90e4d7057f3857da049dfda3d130017d4719bd6b;hp=3d29993486f8651f3a7a86f1c6a68174f7d6d2c1;hpb=58bcc84c9480dae1b21bc24d8396b91fe19e0131;p=lilypond.git diff --git a/flower/memory-stream.cc b/flower/memory-stream.cc index 3d29993486..511657f5fc 100644 --- a/flower/memory-stream.cc +++ b/flower/memory-stream.cc @@ -1,14 +1,26 @@ /* - memory-stream.cc -- implement Memory_out_stream + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2005--2015 Han-Wen Nienhuys - (c) 2005 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ -#include -#include -#include +#include +#include +#include +using namespace std; #include "memory-stream.hh" @@ -17,16 +29,17 @@ */ const int Memory_out_stream::block_size_ = 1024; -cookie_io_functions_t +lily_cookie_io_functions_t Memory_out_stream::functions_ -= { += +{ Memory_out_stream::reader, Memory_out_stream::writer, Memory_out_stream::seeker, Memory_out_stream::cleaner }; -int +ssize_t Memory_out_stream::cleaner (void *cookie) { Memory_out_stream *stream = (Memory_out_stream *) cookie; @@ -40,7 +53,11 @@ Memory_out_stream::Memory_out_stream () size_ = 0; buffer_ = 0; buffer_blocks_ = 0; + file_ = 0; + +#if 0 file_ = fopencookie ((void *) this, "w", functions_); +#endif } Memory_out_stream::~Memory_out_stream () @@ -63,7 +80,7 @@ Memory_out_stream::get_length () const return size_; } -const char * +char const * Memory_out_stream::get_string () const { return buffer_; @@ -71,12 +88,12 @@ Memory_out_stream::get_string () const ssize_t Memory_out_stream::writer (void *cookie, - const char *buffer, - size_t size) + char const *buffer, + size_t size) { Memory_out_stream *stream = (Memory_out_stream *) cookie; - ssize_t newsize = stream->size_ + size; + ssize_t newsize = stream->size_ + (ssize_t) size; bool change = false; while (newsize > stream->buffer_blocks_ * block_size_) @@ -88,32 +105,28 @@ Memory_out_stream::writer (void *cookie, if (change) stream->buffer_ = (char *) realloc (stream->buffer_, - stream->buffer_blocks_ * block_size_); + (size_t) (stream->buffer_blocks_ * block_size_)); memcpy (stream->buffer_ + stream->size_, buffer, size); stream->size_ = newsize; - return size; + return (ssize_t) size; } ssize_t -Memory_out_stream::reader (void *cookie, - char *buffer, - size_t size) +Memory_out_stream::reader (void * /* cookie */, + char * /* buffer */, + size_t /* size */) { - (void) cookie; - (void) buffer; - (void) size; - assert (false); return 0; } -int -Memory_out_stream::seeker (void *, off64_t *, int whence) +ssize_t +Memory_out_stream::seeker (void *, + off64_t *, + size_t) { - (void) whence; - assert (false); return 0; }