// when this function is called we know we're working on a copy of the name, so we can "destruct" it TimingEvent* TimingEvent::GetTimerRec( LPWSTR timerId ) { size_t len = wcslen(timerId); size_t seperator = wcscspn( timerId, L"/|\\" ); if( seperator<len ) timerId[seperator] = 0; TimingEvent* te = m_firstChild; while( te ) { if( !wcscmp(timerId, te->m_name ) ) { if( seperator<len ) te = te->GetTimerRec( &timerId[seperator+1] ); return te; } te = te->m_next; } return NULL; }
TimingEvent* TimerEx::GetTimer( LPCWSTR timerId ) { if( NULL == timerId ) return m_Root; _ASSERT( "init not called" && (m_pDev != NULL) ); size_t len = wcslen(timerId); size_t seperator = wcscspn( timerId, L"/|\\" ); if( seperator < len ) { LPWSTR idCopy = new WCHAR[len+1]; wcscpy_s( idCopy, len+1, timerId ); idCopy[seperator] = 0; TimingEvent* te = m_Root; while( te ) { if( !wcscmp(idCopy, te->m_name ) ) { te = te->GetTimerRec( &idCopy[seperator+1] ); delete[] idCopy; return te; } te = te->m_next; } delete[] idCopy; } else { TimingEvent* te = m_Root; while( te ) { if( !wcscmp(timerId, te->m_name ) ) return te; te = te->m_next; } } return NULL; }
TimingEvent* TimingEvent::GetTimer(LPCWSTR timerId) { size_t len = wcslen(timerId); size_t seperator = wcscspn( timerId, L"/|\\" ); if( seperator<len ) { LPWSTR idCopy = new WCHAR[len+1]; wcscpy_s( idCopy, len+1, timerId ); idCopy[seperator] = 0; TimingEvent* te = m_firstChild; while( te ) { if( !wcscmp(idCopy, te->m_name ) ) { te = te->GetTimerRec( &idCopy[seperator+1] ); delete[] idCopy; return te; } te = te->m_next; } delete[] idCopy; } else { TimingEvent* te = m_firstChild; while( te ) { if( !wcscmp(timerId, te->m_name ) ) return te; te = te->m_next; } } return NULL; }