1 /* 2 * A pipe accessor merely resetting allocated memory for use. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #include "pipe_accessor.h" 23 24 #include <string.h> 25 26 PipeAccessor::PipeAccessor() 27 : Accessor(0) 28 { 29 } 30 31 /* Return the size of the file. */ 32 33 offset_t PipeAccessor::get_size() 34 { 35 return _size; 36 } 37 38 /* Update the size of the file. */ 39 40 void PipeAccessor::set_size(offset_t size) 41 { 42 _size = size; 43 } 44 45 /* Data transfer helper methods. */ 46 47 void PipeAccessor::fill_populated(Flexpage *flexpage) 48 { 49 offset_t filepos = flexpage->base_offset; 50 offset_t addr = flexpage->base_addr; 51 52 /* Tag the region with file state. */ 53 54 flexpage->region->fill(fileid, filepos); 55 56 /* File the flexpage with zero. */ 57 58 memset((void *) addr, 0, flexpage->size); 59 } 60 61 void PipeAccessor::flush_populated(Flexpage *flexpage) 62 { 63 flexpage->region->flush(); 64 } 65 66 // vim: tabstop=4 expandtab shiftwidth=4