Beispiel #1
0
/*** RemoveFile  - free up all resources attached to a particular file
*
* Purpose:
*
*   To free all memory used to keep track of a file.  If the file still
*   appears in some instance lists, it is removed from them.
*
* Input:
*
*   pFileRem - File in question
*
* Output:
*
*   Returns TRUE.
*
* Exceptions:
*
* Notes:
*
*************************************************************************/
void
RemoveFile (
    PFILE    pFileRem
    ) {

    PFILE pFilePrev = (PFILE) &pFileHead;
    PFILE pFileTmp = pFileHead;

    if (pFileRem->refCount > 0) {
        RemoveInstances (pFileRem);
    }

    while (pFileTmp != pFileRem) {
        pFilePrev = pFileTmp;
        pFileTmp = pFileTmp->pFileNext;
        if (pFileTmp == NULL) {
            IntError ("RemoveFile can't find file");
        }
    }


    /*
     * It's important that pFileNext be the first field in a pfile, and we assert
     * that here. This allows us to not special case pFileHead, but adjust it by
     * treating it as the pFileNext of a non-existant structure.
     */
    assert ((void *)&(pFilePrev->pFileNext) == (void *)pFilePrev);
    pFilePrev->pFileNext = pFileTmp->pFileNext;

    FreeFileVM (pFileTmp);

    FREE (pFileTmp->pName);

#if DEBUG
    pFileTmp->id = 0;
#endif

    FREE ((char *) pFileTmp);

    if (pFileTmp == pFileIni) {
        pFileIni = NULL;
    }
}
Beispiel #2
0
/************************************************************************************************
 * CRMGroupInstance::~CRMGroupInstance
 *	Removes all buildings and inhabitants
 *
 * inputs:
 *  none
 *
 * return:
 *	none
 *
 ************************************************************************************************/
CRMGroupInstance::~CRMGroupInstance(void)
{
	// Cleanup
	RemoveInstances ( );
}
    /**
       Update
       /detailed This method parses an entire line of a route file and creates an
                 instance for each line which is then stored in an array.

       @param[in] updateInstances If true (the default) the file will be read.  If false, the
                       file will not be read and instead any pre-loaded testing lines
                       will instead be used.
       @throws SCXInternalErrorException If 11 elements are not parsed for each route file line.
    */
    void NxNetRouteEnumeration::Update(bool updateInstances /* = true */ )
    {
        SCX_LOGTRACE(m_log, L"NxNetRouteEnumeration Update()");

        if( updateInstances )
        {
            m_deps->Init(); // read in data from file
        }

        RemoveInstances();

        vector<std::wstring>::iterator iter;

        iter = m_deps->GetLines().begin();// get iterator at beginning of file

        while (iter != m_deps->GetLines().end())
        {
            std::wstring temp = *iter;
            std::vector<std::wstring> lineElements;
            StrTokenize(temp, lineElements, L"\t\n");

            if (lineElements.size() != 11)
            {
                std::wostringstream error;

                error << L"NxNetRouteEnumeration::Update expected 11 elements in line, got " << std::endl;
                error << lineElements.size() << "." << std::endl;
                throw SCXInternalErrorException(error.str(), SCXSRCLOCATION);
            }


            if (m_log.GetSeverityThreshold() <= SCXCoreLib::eTrace )
            {
                std::wostringstream error;

                error << L"NxNetRouteEnumeration::Update, parsing line of file:" << std::endl;
                error << temp;
                SCX_LOGTRACE( m_log, error.str() );
            }

            // create new instance
            SCXCoreLib::SCXHandle<NxNetRouteInstance> route;
            route = new NxNetRouteInstance(lineElements[0],
                                           lineElements[1],
                                           lineElements[2],
                                           lineElements[3],
                                           lineElements[4],
                                           lineElements[5],
                                           lineElements[6],
                                           lineElements[7],
                                           lineElements[8],
                                           lineElements[9],
                                           lineElements[10]);

            AddInstance(route);

            ++iter;// next line
        }

        SCX_LOGTRACE(m_log, L"NxNetRouteEnumeration Update()");
    }