/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these librararies and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ /* $XConsortium: vm_storage.cc /main/4 1996/07/18 16:05:10 drk $ */ #include "storage/vm_storage.h" #include "utility/mmdb_exception.h" vm_storage::vm_storage( char* _path, char* _name, rep_policy* rep_p): abs_storage( _path, _name, MEM_STORAGE_CODE, rep_p ), f_array(20) { } vm_storage::~vm_storage() { remove(); } void vm_storage::remove() { for ( int i=0; i= f_array.no_elmts() ) { debug(cerr, loc); debug(cerr, f_array.no_elmts()); return -1; } buffer* b = (buffer*)f_array[(int)loc]; if ( b == 0 ) { MESSAGE(cerr, "null pointer"); return -1; } x = b -> get_base(); len = b -> buf_sz(); //debug(cerr, (void*)x); //debug(cerr, len); //MESSAGE(cerr, "========"); return 0; } int vm_storage::updateString(mmdb_pos_t loc, const char* base, int len, int string_ofst, Boolean flush) { //MESSAGE(cerr, "updateString"); //debug(cerr, loc); //debug(cerr, len); if ( loc >= f_array.no_elmts() ) { debug(cerr, loc); debug(cerr, f_array.no_elmts()); return -1; } buffer* b = (buffer*)f_array[(int)loc]; if ( b == 0 ) { MESSAGE(cerr, "null pointer"); return -1; } if ( b -> buf_sz() < len + string_ofst ) b -> expand_chunk(len + string_ofst); /* for (int i=0; i get_base(); memcpy(x+string_ofst, base, len); return 0; } int vm_storage::deleteString (mmdb_pos_t loc, Boolean flush) { return 0; } int vm_storage::allocString (mmdb_pos_t& loc, int len, char*& x, int mode) { //MESSAGE(cerr, "vm: allocate"); //debug(cerr, len); int c = f_array.no_elmts(); if ( c >= f_array.count() ) { f_array.expandWith(10); } buffer* b = new buffer(len==0 ? 1 : len); f_array.insert(b, c) ; f_array.reset_elmts(c+1); x = b -> get_base(); loc = c; //debug(cerr, (void*)x); //debug(cerr, loc); //MESSAGE(cerr, "========"); return 0; } Boolean vm_storage::io_mode(int mode) { return true; }