diff options
author | Max Horn | 2006-02-11 22:45:04 +0000 |
---|---|---|
committer | Max Horn | 2006-02-11 22:45:04 +0000 |
commit | 26ee630756ebdd7c96bccede0881a8c8b98e8f2b (patch) | |
tree | 26e378d5cf990a2b81c2c96e9e683a7f333b62e8 /lure/memory.cpp | |
parent | 2a9a0d4211b1ea5723f1409d91cb95de8984429e (diff) | |
download | scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.tar.gz scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.tar.bz2 scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.zip |
Moved engines to the new engines/ directory
svn-id: r20582
Diffstat (limited to 'lure/memory.cpp')
-rw-r--r-- | lure/memory.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/lure/memory.cpp b/lure/memory.cpp deleted file mode 100644 index 2a24101dd3..0000000000 --- a/lure/memory.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Scumm Interpreter - * Copyright (C) 2005-2006 The ScummVM project - * - * This program 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 2 - * of the License, or (at your option) any later version. - - * This program 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * $URL$ - * $Id$ - * - */ - -#include "lure/memory.h" -#include "common/file.h" - -namespace Lure { - -MemoryBlock *Memory::allocate(uint32 size) { - MemoryBlock *block = new MemoryBlock(size); - return block; -} - -MemoryBlock *Memory::duplicate(MemoryBlock *src) { - MemoryBlock *block = new MemoryBlock(src); - return block; -} - -uint8 *Memory::alloc(uint32 size) { - return (uint8 *) malloc(size); -} - -void Memory::dealloc(uint8 *block) { - free(block); -} - -/*--------------------------------------------------------------------------*/ - -MemoryBlock::MemoryBlock(uint32 size1) { - _data = (uint8 *) malloc(size1); - if (!_data) error ("Failed allocating memory block"); - _size = size1; -} - -MemoryBlock::MemoryBlock(MemoryBlock *src) { - _size = src->size(); - _data = (uint8 *) malloc(_size); - if (!_data) error ("Failed allocating memory block"); - memcpy(_data, src->data(), _size); -} - -MemoryBlock::~MemoryBlock() { - free(_data); -} - -void MemoryBlock::empty() { - ::memset(_data, 0, _size); -} - -void MemoryBlock::memorySet(int c, size_t startIndex, size_t num) { - byte *p = _data + startIndex; - ::memset(p, c, num); -} - -void MemoryBlock::copyFrom(MemoryBlock *src) { - copyFrom(src, 0, 0, src->size()); -} - -void MemoryBlock::copyFrom(MemoryBlock *src, uint32 srcPos, uint32 destPos, uint32 srcLen) { - if ((srcPos + srcLen > src->size()) || (destPos + srcLen > size())) - error("Memory block overrun in block copy"); - - uint8 *pDest = _data + destPos; - uint8 *pSrc = src->data() + srcPos; - memcpy(pDest, pSrc, srcLen); -} - -void MemoryBlock::copyFrom(const byte *src, uint32 srcPos, uint32 destPos, uint32 srcLen) { - byte *pDest = _data + destPos; - const byte *pSrc = src + srcPos; - memcpy(pDest, pSrc, srcLen); -} - -void MemoryBlock::reallocate(uint32 size1) { - _size = size1; - _data = (byte *) realloc(_data, size1); - if (!_data) error ("Failed reallocating memory block"); -} - -void MemoryBlock::saveToFile(const Common::String &filename) { - Common::File *f = new Common::File(); - f->open(filename.c_str(), Common::File::kFileWriteMode); - f->write(_data, _size); - f->close(); - delete f; -} - -} // end of namespace Lure |