Пример #1
0
/* Deinit ncurses and quit. */
void MainQuit (const char * func, const char * error) {
	if (error == NULL) {
		/* Only save settings if we didn't exit on error. */
		WriteCache();
	}
	clear();
	refresh();
	endwin();		/* Make sure no ncurses function is called after this point! */
	
	modifyPIDFile(pid_file_delete);
	
	if (last_signal)
		printf ("Exiting via signal %d.\n", last_signal);
	
	if (error == NULL) {		
		printf (_("Bye.\n\n"));
		
		/* Do this after everything else. If it doesn't work or hang
		   user can ctrl-c without interfering with the program operation
		   (like writing caches). */
		AutoVersionCheck();
		
		exit(0);
	} else {
		printf (_("Aborting program execution!\nAn internal error occured. Snownews has quit, no changes has been saved!\n"));
		printf (_("This shouldn't happen, please submit a bugreport to [email protected], tell me what you where doing and include the output below in your mail.\n"));
		printf ("----\n");
		/* Please don't localize! I don't want to receive Japanese error messages.
		 * Thanks. :)
		 */
		printf ("While executing: %s\n", func);
		printf ("Error as reported by the system: %s\n\n", error);
		exit(1);
	}
}
Пример #2
0
//-------------------------------------------------------------------------
void
DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen )
{
  // Now, check to see if we consider the data to be "too large"
  if (aDataLen > kLargeDatasetSize) {
    // if so, cache it to disk instead of memory
    if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
      return;
    else
			NS_WARNING("Oh no, couldn't write data to the cache file");   
  } 

  mData    = aData;
  mDataLen = aDataLen;  
}
Пример #3
0
//-------------------------------------------------------------------------
void
DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen, bool aIsPrivateData )
{
  // Now, check to see if we consider the data to be "too large"
  // as well as ensuring that private browsing mode is disabled
  if (aDataLen > kLargeDatasetSize && !aIsPrivateData) {
    // if so, cache it to disk instead of memory
    if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
      return;
    else
			NS_WARNING("Oh no, couldn't write data to the cache file");   
  } 

  mData    = aData;
  mDataLen = aDataLen;  
}
Пример #4
0
//-------------------------------------------------------------------------
void
DataStruct::SetData ( nsISupports* aData, uint32_t aDataLen )
{
#if 0  // Remove unnecessary disk caching to accommodate https://www.torproject.org/projects/torbrowser/design/#disk-avoidance
  // Now, check to see if we consider the data to be "too large"
  if (aDataLen > kLargeDatasetSize) {
    // if so, cache it to disk instead of memory
    if ( NS_SUCCEEDED(WriteCache(aData, aDataLen)) )
      return;
    else
			NS_WARNING("Oh no, couldn't write data to the cache file");   
  } 
#endif  // #if 0

  mData    = aData;
  mDataLen = aDataLen;  
}
Пример #5
0
static void BuildList( void ) {
    int numDirs, numDemos;
    void **dirlist, **demolist;
    char *cache, *p;
    unsigned flags;
    size_t len;
    int i;

    // this can be a lengthy process
    S_StopAllSounds();
    m_demos.menu.status = "Building list...";
    SCR_UpdateScreen();

    // list files
    flags = ui_listalldemos->integer ? 0 : FS_TYPE_REAL | FS_PATH_GAME;
    dirlist = FS_ListFiles( m_demos.browse, NULL, flags |
        FS_SEARCH_DIRSONLY, &numDirs );
    demolist = FS_ListFiles( m_demos.browse, DEMO_EXTENSIONS, flags |
        FS_SEARCH_EXTRAINFO, &numDemos );

    // alloc entries
    m_demos.list.items = UI_Malloc( sizeof( demoEntry_t * ) * ( numDirs + numDemos + 1 ) );
    m_demos.list.numItems = 0;
    m_demos.list.curvalue = 0;
    m_demos.list.prestep = 0;

    m_demos.widest_map = 3;
    m_demos.widest_pov = 3;
    m_demos.total_bytes = 0;

    // start with minimum size
    m_demos.menu.size( &m_demos.menu );

    if( m_demos.browse[0] ) {
        BuildDir( "..", ENTRY_UP );
    }

    // add directories
    if( dirlist ) {
        for( i = 0; i < numDirs; i++ ) {
            BuildDir( dirlist[i], ENTRY_DN );
        }
        FS_FreeList( dirlist );
    }    

    m_demos.numDirs = m_demos.list.numItems;

    // add demos
    if( demolist ) {
        CalcHash( demolist );
        if( ( cache = LoadCache( demolist ) ) != NULL ) {
            p = cache + 32 + 1;
            for( i = 0; i < numDemos; i++ ) {
                BuildName( demolist[i], &p );
            }
            FS_FreeFile( cache );
        } else {
            for( i = 0; i < numDemos; i++ ) {
                BuildName( demolist[i], NULL );
                if( ( i & 7 ) == 0 ) {
                    m_demos.menu.size( &m_demos.menu );
                    SCR_UpdateScreen();
                }
            }
        }
        WriteCache();
        FS_FreeList( demolist );
    }

    // update status line and sort
    if( m_demos.list.numItems ) {
        Change( &m_demos.list.generic );
        if( m_demos.list.sortdir ) {
            m_demos.list.sort( &m_demos.list, m_demos.list.sortcol );
        }
    }

    // resize columns
    m_demos.menu.size( &m_demos.menu );

    // format our extra status line
    i = m_demos.list.numItems - m_demos.numDirs;
    len = Q_scnprintf( m_demos.status, sizeof( m_demos.status ),
        "%d demo%s, ", i, i == 1 ? "" : "s" );
    Com_FormatSizeLong( m_demos.status + len, sizeof( m_demos.status ) - len,
        m_demos.total_bytes );
        
    SCR_UpdateScreen();
}
Пример #6
0
int main()
{
    Object* root = 0;
    esInit(&root);

    unsigned long initialMaxFreeCount = PageTable::getFreeCount();
#ifdef VERBOSE
    esReport("Max free count: %d\n", initialMaxFreeCount);
#endif

    unsigned long maxFreeCount = PageTable::getFreeCount();

#ifdef VERBOSE
    esReport("Reserve (maxFreeCount - NON_RESERVED_PAGE) pages.\n");
#endif
    // Reserve (maxFreeCount - NON_RESERVED_PAGE) pages.
    Handle<es::PageSet> pageSet = es::PageSet::createInstance();
    unsigned long reserved = maxFreeCount - NON_RESERVED_PAGE;
    pageSet->reserve(reserved);

    // Check current free pages.
    maxFreeCount = PageTable::getFreeCount();
    TEST(initialMaxFreeCount == maxFreeCount + reserved);

#ifdef VERBOSE
    esReport("Max free count: %d, reserved %d\n", maxFreeCount, reserved);
#endif

    // Create 2 caches.
    // Cache1 uses the reserved pages.
    MemoryStream* backingStore1 = new MemoryStream(0);
    TEST(backingStore1);
    Handle<es::Cache> cache1 = es::Cache::createInstance(backingStore1, pageSet);
    TEST(cache1);

    // Cache2 uses non-reserved pages.
    MemoryStream* backingStore2 = new MemoryStream(0);
    TEST(backingStore2);
    Handle<es::Cache> cache2 = es::Cache::createInstance(backingStore2);
    TEST(cache2);

    CheckAssociatedPage(cache1, 0);
    CheckAssociatedPage(cache2, 0);

    // Associate all non-reserved pages to cache2.
    WriteCache(cache2, NON_RESERVED_PAGE);
    CheckAssociatedPage(cache2, NON_RESERVED_PAGE);

    // Associate one page to cache1.
    WriteCache(cache1, 1);
    CheckAssociatedPage(cache1, 1);
    // Confirm the number of the pages associated to cache2 is not changed.
    CheckAssociatedPage(cache2, NON_RESERVED_PAGE);

    WriteCache(cache2, NON_RESERVED_PAGE + 1);
    // Confirm reserved pages are not associated to cache2.
    CheckAssociatedPage(cache2, NON_RESERVED_PAGE);

    delete backingStore1;
    delete backingStore2;

    esReport("done.\n");
    root->release();
}