[DEBUG] correction of the vector exceding range
This commit is contained in:
parent
a44667d456
commit
1d4c27e7fd
@ -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 ')'
|
||||
|
14
etk/Vector.h
14
etk/Vector.h
@ -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];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user