Commit 0675d987 authored by vigmond's avatar vigmond

Weird memory errors

parent 35293955
......@@ -10,6 +10,8 @@ DataOpacity.cc
DataOpacity.h
DeadDataGUI.cc
DeadDataGUI.h
FlyBy.cc
FlyBy.h
HDF5DataBrowser.cc
HDF5DataBrowser.h
HiLiteWinInfo.cc
......
......@@ -1099,9 +1099,13 @@ TBmeshWin :: get_data( const char *fn, Myslider *mslide )
{
DataClass<DATA_TYPE>* newDataBuffer=NULL;
try {
DataReaderEnum drt = forcedThreaded ? Threaded : getReaderType( fn );
fileType ft = FileTypeFinder( fn );
if( ft == FTascii ) drt = AllInMem;
switch ( forcedThreaded ? Threaded : getReaderType( fn ) ) {
try {
switch ( drt ) {
case AllInMem:
newDataBuffer = new DataAllInMem<DATA_TYPE>( fn, model->pt.num(),
model->base1() );
......
......@@ -89,34 +89,34 @@ class Slave
{
public:
Slave(Master<T>*m=NULL, int datasize=0);
~Slave(){ pthread_cancel( threadID ); delete datareader; delete[] data; }
~Slave(){ delete datareader; free(data); pthread_cancel( threadID ); }
Master<T>* mthread; // PPointer to master
int rdtm; // Read time
T* data; // thread data buffer
int rdtm=-10000; // Read time
T* data=NULL; // thread data buffer
int size; // size of data buffer
bool v_bit; // Valid bit for data
bool v_bit=false; // Valid bit for data
pthread_t threadID; // Thread ID
//sem_t start; // Semaphore to start slave task
//sem_t done; // Semaphore to signal slave done
pthread_mutex_t start; // signal start lave task
pthread_mutex_t done; // signal slave done task
pthread_mutex_t mutex_slave; // Mutex to slave
int unlock; // Indicates slave to post a done semaphore when finished
int unlock=0; // Indicates slave to post a done semaphore when finished
DataReader<T>* datareader; // pointer to derived DataReader class
void resize( int s ){if (size)delete data; data = new T[s];size=s;}
void resize( int s ){if(size)data=(T*)realloc(data,sizeof(T)*s);size=s;}
void master(Master<T>*m,int s){mthread=m;resize(s);}
};
template<class T>
Slave<T>::Slave( Master<T>*_mthread, int datasize ): mthread(_mthread),
size(datasize), rdtm(-10000), v_bit(false), unlock(0), data(NULL)
size(datasize)
{
//sem_init( &start, 0, 0 );
//sem_init( &done, 0, 0 );
pthread_mutex_init ( &start, NULL );
pthread_mutex_init ( &done, NULL );
pthread_mutex_init ( &mutex_slave, NULL );
if ( size ) data = new T[size];
if ( size ) data =(T*)malloc(sizeof(T)*size);
}
......
......@@ -53,7 +53,7 @@ template<class T>
asciireader<T>::~asciireader()
{
gzclose( in );
//gzclose( in );
delete [] buff;
delete [] data;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment