[DEBUG] correction of the vector exceding range

This commit is contained in:
Edouard DUPIN 2012-12-04 21:50:36 +01:00
parent a44667d456
commit 1d4c27e7fd
2 changed files with 17 additions and 0 deletions

View File

@ -137,6 +137,9 @@ char * etk::levelSpace(int32_t level)
int32_t etk::GetLenOfPTheseElem(etk::Vector<int16_t> &data, int32_t startPos)
{
if (startPos>=data.Size()){
return 0;
}
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'

View File

@ -345,6 +345,13 @@ namespace etk
*/
MY_TYPE& Get(int32_t pos)
{
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if( pos>m_size
|| pos<0){
TK_CRITICAL("[CRITICAL] Access to an unexistant data in vector : " << pos << "/ " << m_size);
}
#endif
return m_data[pos];
}
@ -365,6 +372,13 @@ namespace etk
*/
const MY_TYPE& operator[] (int32_t pos) const
{
// NOTE :Do not change log level, this generate error only in debug mode
#if DEBUG_LEVEL > 2
if( pos>m_size
|| pos<0){
TK_CRITICAL("[CRITICAL] Access to an unexistant data in vector : " << pos << "/ " << m_size);
}
#endif
return m_data[pos];
}