<fix> <add "pointer = NULL" after delete a pointer>
The files modified include Database.cpp ISTree.cpp ISStorage.cpp IVTree.cpp IVTree.h IVStorage.cpp KVstore.cppSITree.cpp SIStorage.cpp ClassForVlistCache.h Vlist.cpp
This commit is contained in:
parent
aa9569a643
commit
cc0ea8a803
|
@ -1077,11 +1077,13 @@ Database::unload()
|
|||
{
|
||||
//TODO: do we need to update the pre2num if update queries exist??
|
||||
//or we just neglect this, that is ok because pre2num is just used to count
|
||||
cout << "delete pre2num" << endl;
|
||||
delete[] this->pre2num;
|
||||
this->pre2num = NULL;
|
||||
|
||||
cout << "delete entity buffer" << endl;
|
||||
delete this->entity_buffer;
|
||||
this->entity_buffer = NULL;
|
||||
cout << "delete literal buffer" << endl;
|
||||
delete this->literal_buffer;
|
||||
this->literal_buffer = NULL;
|
||||
|
||||
|
@ -1089,10 +1091,10 @@ Database::unload()
|
|||
//this->vstree->saveTree();
|
||||
//delete this->vstree;
|
||||
//this->vstree = NULL;
|
||||
|
||||
cout << "delete kvstore" << endl;
|
||||
delete this->kvstore;
|
||||
this->kvstore = NULL;
|
||||
|
||||
cout << "delete stringindex" << endl;
|
||||
delete this->stringindex;
|
||||
this->stringindex = NULL;
|
||||
|
||||
|
@ -2300,6 +2302,7 @@ Database::sub2id_pre2id_obj2id_RDFintoSignature(const string _rdf_file)
|
|||
//cout<<"==> end while(true)"<<endl;
|
||||
|
||||
delete[] triple_array;
|
||||
triple_array = NULL;
|
||||
_fin.close();
|
||||
_six_tuples_fout.close();
|
||||
fclose(fp);
|
||||
|
@ -2755,6 +2758,7 @@ Database::insert(std::string _rdf_file, bool _is_restore)
|
|||
}
|
||||
|
||||
delete[] triple_array;
|
||||
triple_array = NULL;
|
||||
long tv_insert = Util::get_cur_time();
|
||||
cout << "after insert, used " << (tv_insert - tv_load) << "ms." << endl;
|
||||
//BETTER:update kvstore and vstree separately, to lower the memory cost
|
||||
|
@ -2849,6 +2853,7 @@ Database::remove(std::string _rdf_file, bool _is_restore)
|
|||
//(only when using group insertion/deletion)
|
||||
//or reduce the array size
|
||||
delete[] triple_array;
|
||||
triple_array = NULL;
|
||||
long tv_remove = Util::get_cur_time();
|
||||
cout << "after remove, used " << (tv_remove - tv_load) << "ms." << endl;
|
||||
|
||||
|
@ -3326,6 +3331,7 @@ Database::insert(const TripleWithObjType* _triples, TYPE_TRIPLE_NUM _triple_num,
|
|||
delete[] id_tuples[i];
|
||||
}
|
||||
delete[] id_tuples;
|
||||
id_tuples = NULL;
|
||||
|
||||
//for (it = old_sigmap.begin(); it != old_sigmap.end(); ++it)
|
||||
//{
|
||||
|
@ -3712,6 +3718,7 @@ Database::remove(const TripleWithObjType* _triples, TYPE_TRIPLE_NUM _triple_num,
|
|||
delete[] id_tuples[i];
|
||||
}
|
||||
delete[] id_tuples;
|
||||
id_tuples = NULL;
|
||||
#else
|
||||
//NOTICE:we deal with deletions one by one here
|
||||
//Callers should save the vstree(node and info) after calling this function
|
||||
|
|
|
@ -603,13 +603,20 @@ ISTree::release(ISNode* _np) const
|
|||
|
||||
ISTree::~ISTree()
|
||||
{
|
||||
cout << "istree : " << endl;
|
||||
cout << "delete stream" << endl;
|
||||
delete this->stream; //maybe NULL
|
||||
stream = NULL;
|
||||
cout << "delete TSM" << endl;
|
||||
delete TSM;
|
||||
TSM = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer, now to delete all nodes in tree!\n");
|
||||
#endif
|
||||
//recursively delete each Node
|
||||
cout << "release" << endl;
|
||||
release(root);
|
||||
cout << "~istree done" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -664,6 +664,7 @@ ISStorage::~ISStorage()
|
|||
printf("already empty the freelist!\n");
|
||||
#endif
|
||||
delete this->minheap;
|
||||
minheap = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer heap!\n");
|
||||
#endif
|
||||
|
|
|
@ -646,15 +646,23 @@ IVTree::AddIntoCache(TYPE_ENTITY_LITERAL_ID _id)
|
|||
|
||||
IVTree::~IVTree()
|
||||
{
|
||||
cout << "IVTree" << endl;
|
||||
cout << "delete Vlist" << endl;
|
||||
delete this->value_list;
|
||||
|
||||
delete this->stream; //maybe NULL
|
||||
value_list = NULL;
|
||||
cout << "delete stream" << endl;
|
||||
delete this->stream;//maybe NULL
|
||||
this->stream = NULL;
|
||||
cout << "delete TSM" << endl;
|
||||
delete TSM;
|
||||
TSM = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer, now to delete all nodes in tree!\n");
|
||||
#endif
|
||||
//recursively delete each Node
|
||||
cout << "release" << endl;
|
||||
release(root);
|
||||
cout << "~IVTree done" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -88,6 +88,7 @@ public:
|
|||
void resetStream();
|
||||
bool range_query(unsigned _key1, unsigned _key2);
|
||||
bool save();
|
||||
|
||||
void AddIntoCache(TYPE_PREDICATE_ID _id);
|
||||
void AddIntoCache(TYPE_ENTITY_LITERAL_ID _id);
|
||||
~IVTree();
|
||||
|
|
|
@ -714,6 +714,7 @@ IVStorage::~IVStorage()
|
|||
printf("already empty the freelist!\n");
|
||||
#endif
|
||||
delete this->minheap;
|
||||
this->minheap = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer heap!\n");
|
||||
#endif
|
||||
|
|
|
@ -59,25 +59,33 @@ KVstore::flush()
|
|||
void
|
||||
KVstore::release()
|
||||
{
|
||||
cout << "delete entity2id" << endl;
|
||||
delete this->entity2id;
|
||||
this->entity2id = NULL;
|
||||
cout << "delete id2eneity" << endl;
|
||||
delete this->id2entity;
|
||||
this->id2entity = NULL;
|
||||
|
||||
cout << "delete literal2id" << endl;
|
||||
delete this->literal2id;
|
||||
this->literal2id = NULL;
|
||||
cout << "delete id2leteral" << endl;
|
||||
delete this->id2literal;
|
||||
this->id2literal = NULL;
|
||||
|
||||
cout << "delete p2id" << endl;
|
||||
delete this->predicate2id;
|
||||
this->predicate2id = NULL;
|
||||
cout << "delte id2p" << endl;
|
||||
delete this->id2predicate;
|
||||
this->id2predicate = NULL;
|
||||
|
||||
cout << "delete s2v" << endl;
|
||||
delete this->subID2values;
|
||||
this->subID2values = NULL;
|
||||
cout << "delete p2v" << endl;
|
||||
delete this->preID2values;
|
||||
this->preID2values = NULL;
|
||||
cout << "delete o2v" << endl;
|
||||
delete this->objID2values;
|
||||
this->objID2values = NULL;
|
||||
}
|
||||
|
|
|
@ -454,12 +454,17 @@ SITree::release(SINode* _np) const
|
|||
|
||||
SITree::~SITree()
|
||||
{
|
||||
cout << "SITree" << endl;
|
||||
cout << "delete TSM" << endl;
|
||||
delete TSM;
|
||||
TSM = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer, now to delete all nodes in tree!\n");
|
||||
#endif
|
||||
cout << "release" << endl;
|
||||
//recursively delete each SINode
|
||||
release(root);
|
||||
cout << "~SITree done" << endl;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -649,6 +649,7 @@ SIStorage::~SIStorage()
|
|||
printf("already empty the freelist!\n");
|
||||
#endif
|
||||
delete this->minheap;
|
||||
minheap = NULL;
|
||||
#ifdef DEBUG_KVSTORE
|
||||
printf("already empty the buffer heap!\n");
|
||||
#endif
|
||||
|
|
|
@ -28,6 +28,10 @@ public:
|
|||
}
|
||||
~Longlist_inMem()
|
||||
{
|
||||
if(_str != NULL) delete []_str;
|
||||
if(_str != NULL)
|
||||
{
|
||||
delete [] _str;
|
||||
_str = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -150,7 +150,7 @@ VList::AllocBlock()
|
|||
unsigned t = p->num;
|
||||
this->freelist->next = p->next;
|
||||
delete p;
|
||||
|
||||
p = NULL;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue