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