From: Dejan L. <de...@us...> - 2004-06-12 22:48:39
|
Update of /cvsroot/rtk/rtk/src/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26585/src/core Modified Files: Buffer.cpp Log Message: Latest Buffer code and Dev-C++ project files. Index: Buffer.cpp =================================================================== RCS file: /cvsroot/rtk/rtk/src/core/Buffer.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Buffer.cpp 12 Jun 2004 07:32:53 -0000 1.7 --- Buffer.cpp 12 Jun 2004 22:48:29 -0000 1.8 *************** *** 42,51 **** #include <string.h> /* memcpy() */ #include <stdlib.h> /* malloc() */ - #include <rtk/Buffer.h> ! #ifdef _DEBUG ! #include <rtk/debug.h> ! #include <rtk/File.h> #endif --- 42,49 ---- #include <string.h> /* memcpy() */ #include <stdlib.h> /* malloc() */ #include <rtk/Buffer.h> ! #if _DEBUG ! #include <rtk/debug.h> #endif *************** *** 68,79 **** if(!_data) _data = (uchar*)malloc(_allocated); ! else _data = (uchar*)realloc(_data, _allocated); ! ! /* ! uchar* newdata = (uchar*) malloc(_allocated); ! memcpy(newdata, _data, _size); ! free(_data); ! _data = newdata; ! */ } // if return (_data + _size); --- 66,70 ---- if(!_data) _data = (uchar*)malloc(_allocated); ! else _data = (uchar*)realloc(_data, _allocated); } // if return (_data + _size); *************** *** 113,143 **** } // Fill() ! #ifdef _DEBUG ! // Code taken from eFLTK ... ! ! void Buffer::FromFile(const String& arg_fname) { ! File f(arg_fname, File::READ|File::BINARY); ! if(!f.IsOpen()) return; // Some error checks should be here... ! f.Seek(0, IO::END); ! long size = f.Tell(); ! f.Seek(0, IO::BEGIN); Allocate(size+1); _data[size] = '\0'; ! _size = f.Read(_data, size); ! f.Close(); ! } ! void Buffer::ToFile(const String& arg_fname) const { ! if(!_size) return; ! File f(arg_fname, File::WRITE|File::CREATE|File::BINARY); ! if(f.IsOpen()) { ! f.Write(_data, _size); ! f.Close(); } ! } ! #endif }; // Rtk --- 104,127 ---- } // Fill() ! void Buffer::From(IO* arg_io) { ! if(!arg_io->CanRead()) return; // Some error checks should be here... ! arg_io->Seek(0, IO::END); ! long size = arg_io->Tell(); ! arg_io->Seek(0, IO::BEGIN); Allocate(size+1); _data[size] = '\0'; ! _size = arg_io->Read(_data, size); ! } // From() ! void Buffer::To(IO* arg_io) { ! if (!_size) return; ! if (arg_io->CanWrite()) ! { ! arg_io->Write(_data, _size); } ! } // To() }; // Rtk |