Commit a8078faf authored by Pavel Vainerman's avatar Pavel Vainerman

Исправил ошибку в TableBlockStorage приводившую в SEGFAULT если не удалось открыть файл.

parent 49cb2f00
......@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt11
Release: alt12
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
......@@ -191,6 +191,9 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Wed Mar 23 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt12
- fixed bug in TableBlockStorage interface
* Thu Mar 17 2011 Pavel Vainerman <pv@altlinux.ru> 1.0-alt11
- fixed bug in MBTCPMaster (query optimization)
......
......@@ -28,14 +28,16 @@
#include "Storages.h"
TableBlockStorage::TableBlockStorage()
TableBlockStorage::TableBlockStorage():
file(NULL),
mem(0)
{
file=NULL;
}
TableBlockStorage::TableBlockStorage(const char* name, int byte_sz, int key_sz, int inf_sz, int inf_count, int block_num, int block_lim, int seek, bool cr)
TableBlockStorage::TableBlockStorage(const char* name, int byte_sz, int key_sz, int inf_sz, int inf_count, int block_num, int block_lim, int seek, bool cr):
file(NULL),
mem(0)
{
file=NULL;
if(!open(name, byte_sz, key_sz, inf_sz, inf_count, block_num, block_lim, seek))
{
if(cr)
......@@ -47,9 +49,8 @@ TableBlockStorage::TableBlockStorage(const char* name, int byte_sz, int key_sz,
TableBlockStorage::~TableBlockStorage()
{
if( mem!=NULL ) delete mem;
if(file!=NULL) fclose(file);
delete mem;
if(file!=NULL) fclose(file);
}
bool TableBlockStorage::keyCompare(int i, void* key)
......
......@@ -29,7 +29,8 @@
#include "Storages.h"
TableStorage::TableStorage(const char* name, int inf_sz, int sz, int seek)
TableStorage::TableStorage( const char* name, int inf_sz, int sz, int seek ):
file(0)
{
file = fopen(name, "r+");
inf_size=inf_sz;
......@@ -105,7 +106,8 @@ TableStorage::TableStorage(const char* name, int inf_sz, int sz, int seek)
TableStorage::~TableStorage()
{
fclose(file);
if( file )
fclose(file);
}
int TableStorage::addRow(char* key, char* value)
......
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