I re-tested CList again with 1 entry, it does not work.
void OnStart() {
CList list;
CString str1;
str1.Assign("a");
list.Add(GetPointer(str1));
list.Sort(0);
CString str2;
str2.Assign("b");
CString *found=list.Search(GetPointer(str2));
if (found)
Print(found.Str());
}
"a" is printed and the logic searched for "b".
by the way, if the same logic is copied to Arrays, it crashed because QuickSearch returns 1 where there is only 1 element in the array (index 0).
bool CArrayObj::Delete(int index) { //--- checking if(index>=m_data_total) return(false); //--- delete if(index<0 || index<m_data_total-1) MemMove(index,index+1,m_data_total-index-1); m_data_total--; //--- return(true); }
I thought Delete method should delete the object at index, but instead it just over write the pointer without releasing it! Took me 3 days to debug my code why a pointer is not released properly!!!
Is anyone going to respond to fix this?
Memmove is never called if I want to delete the last element of the array, in this case index would be equal to m_data_total-1. The pointer will not be released.
Thanks for your messages.
All changes will available at the next build. At this moment you can use attached file.
Alexvd,
Thanks for your quick fix offer:
if(index<m_data_total-1) { if(index>=0) MemMove(index,index+1,m_data_total-index-1); } else { if(CheckPointer(m_data[index])==POINTER_DYNAMIC) delete m_data[index]; }
but i think you need to check the freemode flag before deleting.
Rosh,
I m disappointed that Build 353 does not fix this issue.
Rosh,
I m disappointed that Build 353 does not fix this issue.
I don't know what you say about. What issue do you exactly mean?
bool CArrayObj::Delete(int index) { //--- checking if(index>=m_data_total) return(false); //--- delete if(index<0 || index<m_data_total-1) MemMove(index,index+1,m_data_total-index-1); m_data_total--; //--- return(true); }
Object is not deleted when index=m_data_total-1.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have raised the quicksearch problem in CList and build 350 has fixed it. However, why you didnt also check the quicksearch in all the array libraries? Quicksearch they also use the old algo in CList and fail!
CList::QuickSearch
CArrayString::QuickSearch