bool CacheOpen( file_list *list ) /**************************************/ { infilelist *file; unsigned numblocks; char **cache; if( list == NULL ) return( TRUE ); file = list->file; if( file->flags & INSTAT_IOERR ) return( FALSE ); if( DoObjOpen( file ) ) { file->flags |= INSTAT_IN_USE; } else { file->flags |= INSTAT_IOERR; return( FALSE ); } if( file->len == 0 ) { file->len = QFileSize( file->handle ); if( file->len == 0 ) { LnkMsg( ERR+MSG_BAD_OBJECT, "s", file->name ); file->flags |= INSTAT_IOERR; return( FALSE ); } } if( !(file->flags & INSTAT_SET_CACHE) ) { if( LinkFlags & CACHE_FLAG ) { file->flags |= INSTAT_FULL_CACHE; } else if( LinkFlags & NOCACHE_FLAG ) { file->flags |= INSTAT_PAGE_CACHE; } else { if( file->flags & INSTAT_LIBRARY ) { file->flags |= INSTAT_PAGE_CACHE; } else { file->flags |= INSTAT_FULL_CACHE; } } } if( file->cache == NULL ) { if( file->flags & INSTAT_FULL_CACHE ) { _ChkAlloc( file->cache, file->len ); if( file->currpos != 0 ) { QLSeek( file->handle, 0, SEEK_SET, file->name ); } QRead( file->handle, file->cache, file->len, file->name ); file->currpos = file->len; } else { numblocks = NumCacheBlocks( file->len ); _Pass1Alloc( file->cache, numblocks * sizeof( char * ) ); cache = file->cache; while( numblocks > 0 ) { *cache = NULL; cache++; numblocks--; } } } return( TRUE ); }
static comdat_info * AllocCDatInfo( void ) /****************************************/ { comdat_info * info; if( FreedInfos != NULL ) { info = FreedInfos; FreedInfos = info->next; } else { _Pass1Alloc( info, sizeof(comdat_info) ); } info->pieces = NULL; return( info ); }
static comdat_piece * AllocCDatPiece( void ) /******************************************/ { comdat_piece * piece; if( FreedPieces != NULL ) { piece = FreedPieces; FreedPieces = piece->next; } else { _Pass1Alloc( piece, sizeof(comdat_piece) ); } memset( piece, 0, sizeof(comdat_piece) ); return( piece ); }
static edgelist * AllocEdge( void ) /*********************************/ { edgelist * edge; if( FreedEdges != NULL ) { edge = FreedEdges; FreedEdges = edge->next; } else { _Pass1Alloc( edge, sizeof(edgelist) ); } memset(edge, 0, sizeof *edge); return( edge ); }