vendredi 21 avril 2017

std::vector

I wrote debug system for my tool. It save vector arrays in memory, and save it to dump file after crash.

vector<string> HelperLog( 100 );
void __stdcall  AddNewLineToHelperLog( const char * s, int line )
{
    if ( bDllLogEnable && s && s[ 0 ] != '\0' )
    {
        memset( ErrorHelperBuffer, 0, 1024 );
        sprintf_s( ErrorHelperBuffer, "Func:%s:%i", s, line );
        //ExternalLog( ErrorHelperBuffer, LogType::HelperLog );
        if ( HelperLog.size( ) > 20 )
        {
            //HelperLog[ 0 ].clear( );
            HelperLog.erase( HelperLog.begin( ) );
        }

        //std::string logstr = string( s );
        HelperLog.push_back( s );
    }
}

I got random crash in this function. Please help, how to fix it or bypass? Crash at vector push_back.

Tool have only one thread, and this function called in all functions used in my tool.

Aucun commentaire:

Enregistrer un commentaire