/* ----------------------------------------------------------------------------- Function: CAL_Shutdown() -Shutdown module. Parameters: Nothing. Returns: Nothing. Notes: Frees grstarts, pictable and grsegs data. Closes grhandle file handle. ----------------------------------------------------------------------------- */ PUBLIC void CAL_Shutdown( void ) { W32 i; if( grstarts ) { MM_FREE( grstarts ); } if( pictable ) { MM_FREE( pictable ); } if( grhandle ) { fclose( grhandle ); } for( i = 0; i < NUMCHUNKS; ++i ) { if( grsegs[ i ] ) { MM_FREE( grsegs[ i ] ); } } }
void SampleBuffer::loadFromBase64( const QString & _data ) { char * dst = NULL; int dsize = 0; base64::decode( _data, &dst, &dsize ); #ifdef LMMS_HAVE_FLAC_STREAM_DECODER_H QByteArray orig_data = QByteArray::fromRawData( dst, dsize ); QBuffer ba_reader( &orig_data ); ba_reader.open( QBuffer::ReadOnly ); QBuffer ba_writer; ba_writer.open( QBuffer::WriteOnly ); flacStreamDecoderClientData cdata = { &ba_reader, &ba_writer } ; FLAC__StreamDecoder * flac_dec = FLAC__stream_decoder_new(); FLAC__stream_decoder_set_read_callback( flac_dec, flacStreamDecoderReadCallback ); FLAC__stream_decoder_set_write_callback( flac_dec, flacStreamDecoderWriteCallback ); FLAC__stream_decoder_set_error_callback( flac_dec, flacStreamDecoderErrorCallback ); FLAC__stream_decoder_set_metadata_callback( flac_dec, flacStreamDecoderMetadataCallback ); FLAC__stream_decoder_set_client_data( flac_dec, &cdata ); FLAC__stream_decoder_init( flac_dec ); FLAC__stream_decoder_process_until_end_of_stream( flac_dec ); FLAC__stream_decoder_finish( flac_dec ); FLAC__stream_decoder_delete( flac_dec ); ba_reader.close(); orig_data = ba_writer.buffer(); printf("%d\n", (int) orig_data.size() ); m_origFrames = orig_data.size() / sizeof( sampleFrame ); MM_FREE( m_origData ); m_origData = MM_ALLOC( sampleFrame, m_origFrames ); memcpy( m_origData, orig_data.data(), orig_data.size() ); #else /* LMMS_HAVE_FLAC_STREAM_DECODER_H */ m_origFrames = dsize / sizeof( sampleFrame ); MM_FREE( m_origData ); m_origData = MM_ALLOC( sampleFrame, m_origFrames ); memcpy( m_origData, dst, dsize ); #endif delete[] dst; m_audioFile = QString(); update(); }
void message_data_race(struct messaging_state *state, unsigned int eip, unsigned int most_recent_syscall, bool confirmed) { struct output_message m; m.tag = DATA_RACE; m.content.dr.eip = eip; m.content.dr.most_recent_syscall = most_recent_syscall; m.content.dr.confirmed = confirmed; /* pretty print the data race addr to propagate to master program */ char *func; char *file; int line; bool res = symtable_lookup(eip, &func, &file, &line); if (!res || func == NULL) { scnprintf(m.content.dr.pretty_printed, MESSAGE_BUF_SIZE, "0x%.8x <unknown>", eip); } else if (file == NULL) { scnprintf(m.content.dr.pretty_printed, MESSAGE_BUF_SIZE, "0x%.8x in %s <source unknown>", eip, func); } else { scnprintf(m.content.dr.pretty_printed, MESSAGE_BUF_SIZE, "0x%.8x in %s (%s:%d)", eip, func, file, line); } if (res) { if (func != NULL) MM_FREE(func); if (file != NULL) MM_FREE(file); } send(state, &m); }
/** * @brief Set the number of energy groups for this Material. * @param num_groups the number of energy groups. */ void Material::setNumEnergyGroups(const int num_groups) { if (num_groups < 0) log_printf(ERROR, "Unable to set the number of energy groups for " "material %d to %d", _id, num_groups); _num_groups = num_groups; /* Free old data arrays if they were allocated for a previous simulation */ /* If data is vector aligned */ if (_data_aligned) { if (_sigma_t != NULL) MM_FREE(_sigma_t); if (_sigma_s != NULL) MM_FREE(_sigma_s); if (_sigma_f != NULL) MM_FREE(_sigma_f); if (_nu_sigma_f != NULL) MM_FREE(_nu_sigma_f); if (_chi != NULL) MM_FREE(_chi); } /* Data is not vector aligned */ else { if (_sigma_t != NULL) delete [] _sigma_t; if (_sigma_s != NULL) delete [] _sigma_s; if (_sigma_f != NULL) delete [] _sigma_f; if (_nu_sigma_f != NULL) delete [] _nu_sigma_f; if (_chi != NULL) delete [] _chi; } /* Allocate memory for data arrays */ _sigma_t = new FP_PRECISION[_num_groups]; _sigma_f = new FP_PRECISION[_num_groups]; _nu_sigma_f = new FP_PRECISION[_num_groups]; _chi = new FP_PRECISION[_num_groups]; _sigma_s = new FP_PRECISION[_num_groups*_num_groups]; /* Assign the null vector to each data array */ memset(_sigma_t, 0.0, sizeof(FP_PRECISION) * _num_groups); memset(_sigma_f, 0.0, sizeof(FP_PRECISION) * _num_groups); memset(_nu_sigma_f, 0.0, sizeof(FP_PRECISION) * _num_groups); memset(_chi, 0.0, sizeof(FP_PRECISION) * _num_groups); memset(_sigma_s, 0.0, sizeof(FP_PRECISION) * _num_groups * _num_groups); }
SampleBuffer::~SampleBuffer() { if( m_origData != NULL ) MM_FREE( m_origData ); MM_FREE( m_data ); }
/** * @brief Allocates memory for FSR source arrays. * @details Deletes memory for old source arrays if they were allocated for a * previous simulation. */ void VectorizedSolver::initializeSourceArrays() { /* Delete old sources arrays if they exist */ if (_reduced_sources != NULL) MM_FREE(_reduced_sources); if (_fixed_sources != NULL) MM_FREE(_fixed_sources); int size = _num_FSRs * _num_groups * sizeof(FP_PRECISION); /* Allocate aligned memory for all source arrays */ try{ _reduced_sources = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); _fixed_sources = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); } catch(std::exception &e) { log_printf(ERROR, "Could not allocate memory for FSR sources"); } /* Initialize fixed sources to zero */ memset(_fixed_sources, 0.0, size); /* Populate fixed source array with any user-defined sources */ initializeFixedSources(); }
/** * @brief Computes the total source (fission, scattering, fixed) in each FSR. * @details This method computes the total source in each FSR based on * this iteration's current approximation to the scalar flux. */ void VectorizedSolver::computeFSRSources() { #pragma omp parallel default(none) { int tid; Material* material; FP_PRECISION* sigma_t; FP_PRECISION* sigma_s; FP_PRECISION* fiss_mat; FP_PRECISION scatter_source, fission_source; int size = _num_groups * sizeof(FP_PRECISION); FP_PRECISION* fission_sources = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); FP_PRECISION* scatter_sources = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); /* For all FSRs, find the source */ #pragma omp for schedule(guided) for (int r=0; r < _num_FSRs; r++) { tid = omp_get_thread_num(); material = _FSR_materials[r]; sigma_t = material->getSigmaT(); sigma_s = material->getSigmaS(); fiss_mat = material->getFissionMatrix(); /* Compute scatter + fission source for group G */ for (int G=0; G < _num_groups; G++) { for (int v=0; v < _num_vector_lengths; v++) { #pragma simd vectorlength(VEC_LENGTH) for (int g=v*VEC_LENGTH; g < (v+1)*VEC_LENGTH; g++) { scatter_sources[g] = sigma_s[G*_num_groups+g] * _scalar_flux(r,g); fission_sources[g] = fiss_mat[G*_num_groups+g] * _scalar_flux(r,g); } } #ifdef SINGLE scatter_source=cblas_sasum(_num_groups, scatter_sources, 1); fission_source=cblas_sasum(_num_groups, fission_sources, 1); #else scatter_source=cblas_dasum(_num_groups, scatter_sources, 1); fission_source=cblas_dasum(_num_groups, fission_sources, 1); #endif fission_source /= _k_eff; /* Compute total (scatter+fission+fixed) reduced source */ _reduced_sources(r,G) = _fixed_sources(r,G); _reduced_sources(r,G) += scatter_source + fission_source; _reduced_sources(r,G) *= ONE_OVER_FOUR_PI / sigma_t[G]; } } MM_FREE(fission_sources); MM_FREE(scatter_sources); } }
/** * @brief Compute \f$ k_{eff} \f$ from successive fission sources. */ void VectorizedSolver::computeKeff() { FP_PRECISION fission; int size = _num_FSRs * sizeof(FP_PRECISION); FP_PRECISION* FSR_rates = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); size = _num_threads * _num_groups * sizeof(FP_PRECISION); FP_PRECISION* group_rates = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); #pragma omp parallel { int tid = omp_get_thread_num() * _num_groups; Material* material; FP_PRECISION* sigma; FP_PRECISION volume; /* Compute the new nu-fission rates in each FSR */ #pragma omp for schedule(guided) for (int r=0; r < _num_FSRs; r++) { volume = _FSR_volumes[r]; material = _FSR_materials[r]; sigma = material->getNuSigmaF(); /* Loop over each energy group vector length */ for (int v=0; v < _num_vector_lengths; v++) { /* Loop over energy groups within this vector */ #pragma simd vectorlength(VEC_LENGTH) for (int e=v*VEC_LENGTH; e < (v+1)*VEC_LENGTH; e++) group_rates[tid+e] = sigma[e] * _scalar_flux(r,e); } #ifdef SINGLE FSR_rates[r] = cblas_sasum(_num_groups, &group_rates[tid], 1) * volume; #else FSR_rates[r] = cblas_dasum(_num_groups, &group_rates[tid], 1) * volume; #endif } } /* Reduce new fission rates across FSRs */ #ifdef SINGLE fission = cblas_sasum(_num_FSRs, FSR_rates, 1); #else fission = cblas_dasum(_num_FSRs, FSR_rates, 1); #endif _k_eff *= fission; MM_FREE(FSR_rates); MM_FREE(group_rates); }
/** * @brief Destructor deletes Track boundary angular flux and * and FSR scalar flux and source arrays. */ VectorizedSolver::~VectorizedSolver() { if (_boundary_flux != NULL) { MM_FREE(_boundary_flux); _boundary_flux = NULL; } if (_boundary_leakage != NULL) { MM_FREE(_boundary_leakage); _boundary_leakage = NULL; } if (_scalar_flux != NULL) { MM_FREE(_scalar_flux); _scalar_flux = NULL; } if (_fission_sources != NULL) { MM_FREE(_fission_sources); _fission_sources = NULL; } if (_scatter_sources != NULL) { MM_FREE(_scatter_sources); _scatter_sources = NULL; } if (_source != NULL) { MM_FREE(_source); _source = NULL; } if (_old_source != NULL) { MM_FREE(_old_source); _old_source = NULL; } if (_reduced_source != NULL) { MM_FREE(_reduced_source); _reduced_source = NULL; } if (_thread_taus != NULL) { MM_FREE(_thread_taus); _thread_taus = NULL; } if (_thread_exponentials != NULL) { MM_FREE(_thread_exponentials); _thread_exponentials = NULL; } }
/* returns true if the state changed. */ bool test_update_state(conf_object_t *cpu, struct test_state *t, struct sched_state *s) { if (anybody_alive(cpu, t, s)) { if (!t->test_is_running) { lsprintf(BRANCH, "a test appears to be starting - "); print_qs(BRANCH, s); printf(BRANCH, "\n"); t->test_is_running = true; return true; } } else { if (t->test_is_running) { lsprintf(BRANCH, "a test appears to be ending - "); print_qs(BRANCH, s); printf(BRANCH, "\n"); if (t->current_test) { MM_FREE(t->current_test); t->current_test = NULL; } t->test_is_running = false; return true; } } return false; }
static inline void timer_execute(struct timer *T) { int idx = T->time & TIME_NEAR_MASK; while (T->near[idx].head.next) { struct timer_node *current = link_clear(&T->near[idx]); UNLOCK(T); // dispatch_list don't need lock T do { struct timer_event * event = (struct timer_event *)(current+1); T->dispather(event->ud, event->data, event->sz); struct timer_node * temp = current; current=current->next; if(event->period > 0) { //update expired temp->next = NULL; temp->expire = TI->time + event->period; add_node(TI, temp ); } else { MM_FREE(temp); } } while (current); LOCK(T); } }
void found_a_bug(struct ls_state *ls) { if (DECISION_INFO_ONLY == 0) { lsprintf(BUG, COLOUR_BOLD COLOUR_RED "**** A bug was found! ****\n"); lsprintf(BUG, COLOUR_BOLD COLOUR_RED "**** Decision trace follows. ****\n"); } else { lsprintf(ALWAYS, COLOUR_BOLD COLOUR_GREEN "(No bug was found.)\n"); } print_tree_from(ls->save.current, ls->save.next_tid); char *stack = stack_trace(ls->cpu0, ls->eip, ls->sched.cur_agent->tid); lsprintf(BUG, "Stack: %s\n", stack); MM_FREE(stack); PRINT_TREE_INFO(BUG, ls); if (BREAK_ON_BUG) { lsprintf(ALWAYS, COLOUR_BOLD COLOUR_YELLOW "Now giving you the debug prompt. Good luck!\n"); SIM_break_simulation(NULL); } else { SIM_quit(LS_BUG_FOUND); } }
void LadspaEffect::pluginDestruction() { if( !isOkay() ) { return; } delete m_controls; for( ch_cnt_t proc = 0; proc < processorCount(); proc++ ) { Ladspa2LMMS * manager = Engine::getLADSPAManager(); manager->deactivate( m_key, m_handles[proc] ); manager->cleanup( m_key, m_handles[proc] ); for( int port = 0; port < m_portCount; port++ ) { port_desc_t * pp = m_ports.at( proc ).at( port ); if( m_inPlaceBroken || pp->rate != CHANNEL_OUT ) { if( pp->buffer) MM_FREE( pp->buffer ); } delete pp; } m_ports[proc].clear(); } m_ports.clear(); m_handles.clear(); m_portControls.clear(); }
/** * \brief List directories and files. */ PRIVATE void FS_Dir_f( void ) { char *path = NULL; char findname[1024]; char wildcard[1024] = "*.*"; char **dirnames; int ndirs; if ( Cmd_Argc() != 1 ) { com_strlcpy( wildcard, Cmd_Argv( 1 ), sizeof( wildcard ) ); } while ( ( path = FS_NextPath( path ) ) != NULL ) { char *tmp = findname; com_snprintf( findname, sizeof( findname ), "%s%c%s", path, PATH_SEP, wildcard ); while ( *tmp != 0 ) { if ( *tmp == '\\' ) *tmp = '/'; tmp++; } Com_Printf( "Directory of %s\n", findname ); Com_Printf( "----\n" ); if ( ( dirnames = FS_ListFiles( findname, &ndirs, 0, 0 ) ) != 0 ) { int i; for ( i = 0; i < ndirs-1; i++ ) { if ( strrchr( dirnames[i], PATH_SEP ) ) Com_Printf( "%s\n", strrchr( dirnames[i], PATH_SEP ) + 1 ); else Com_Printf( "%s\n", dirnames[i] ); MM_FREE( dirnames[i] ); } MM_FREE( dirnames ); } Com_Printf( "\n" ); }; }
/** * \brief Shutdown page cache. */ PUBLIC void PageFile_Shutdown( void ) { if( file_handle_page ) { fclose( file_handle_page ); file_handle_page = NULL; } MM_FREE( PMPages ); }
/** * \brief Find texture based on file name * \param[in] name Name of the texture to find. * \param[in] type Type of texture (see texturetype_t). * \return r_notexture if the texture is not found, otherwise it will return a valid texture_t structure. */ PUBLIC texture_t *TM_FindTexture( const char *name, texturetype_t type ) { texture_t *tex; int i, len; W8 *data; /* raw texture data */ W16 width, height; /* width, height of texture */ W16 bytes; if( ! name || ! *name ) { return r_notexture; } // Check for file extension len = strlen( name ); if( len < 5 ) { return r_notexture; } // look for it in the texture cache for( i = 0, tex = ttextures; i < numttextures; ++i, ++tex ) { if( ! strcmp( name, tex->name ) ) { tex->registration_sequence = texture_registration_sequence; return tex; } } // // load the texture from disk // data = NULL; if( ! strcmp( name + len - 4, ".tga" ) ) { LoadTGA( name, &data, &width, &height, &bytes ); if( ! data ) { return r_notexture; } tex = TM_LoadTexture( name, data, width, height, type, bytes ); } else { return r_notexture; } MM_FREE( data ); return tex; }
void gc_set_config_line_number(generic_cache_t *gc, int line_number) { gc->config.line_number = line_number; /* re-allocate the lines */ MM_FREE(gc->lines); gc->lines = MM_ZALLOC(gc->config.line_number, cache_line_t); update_precomputed_values(gc); }
/** * @brief Allocates memory for Track boundary angular and FSR scalar fluxes. * @details Deletes memory for old flux arrays if they were allocated for a * previous simulation. */ void VectorizedSolver::initializeFluxArrays() { /* Delete old flux arrays if they exist */ if (_boundary_flux != NULL) MM_FREE(_boundary_flux); if (_scalar_flux != NULL && !_user_fluxes) MM_FREE(_scalar_flux); if (_old_scalar_flux != NULL) MM_FREE(_old_scalar_flux); if (_delta_psi != NULL) MM_FREE(_delta_psi); if (_thread_taus != NULL) MM_FREE(_thread_taus); int size; /* Allocate aligned memory for all flux arrays */ try{ size = 2 * _tot_num_tracks * _num_groups * _num_polar; size *= sizeof(FP_PRECISION); _boundary_flux = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); size = _num_FSRs * _num_groups * sizeof(FP_PRECISION); _scalar_flux = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); _old_scalar_flux = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); size = _num_threads * _num_groups * sizeof(FP_PRECISION); _delta_psi = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); size = _num_threads * _polar_times_groups * sizeof(FP_PRECISION); _thread_taus = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); } catch(std::exception &e) { log_printf(ERROR, "Could not allocate memory for the fluxes"); } }
/** * \brief Delete link list and elements. * \param[in] list Pointer to linkList_t structure. * \return On success true, otherwise false. */ PUBLIC wtBoolean linkList_deleteFull( linkList_t *list ) { if( list ) { linkList_t *current; while( (current = list) ) { list = list->next; if( current->element ) { MM_FREE( current->element ); } MM_FREE( current ); } return true; } return false; }
/** * \brief Remove node. * \param[in] current Node to remove. * \param[in] previous Previous Node in chain. * \return On success true, otherwise false. */ PUBLIC wtBoolean linkList_quickRemoveNode( linkList_t *current, linkList_t *previous ) { if( current && previous ) { previous->next = current->next; MM_FREE( current ); return true; } return false; }
PRIVATE void DecodeText( W16 version ) { char *text; int artnum; int endextern; int i; int length; FILE *fhandle; int limit; limit = 6; if( version & SOD_PAK ) { endextern = 168; fhandle = fopen( "sod.txt", "wb" ); if( ! fhandle ) { return; } limit = 1; } else if( version & WL6_PAK ) { endextern = 143; fhandle = fopen( "wl6.txt", "wb" ); if( ! fhandle ) { return; } } else { return; } for( i = 0 ; i < limit ; ++i ) { artnum = endextern + i; CA_CacheGrChunk( artnum, version ); text = (char *)grsegs[ artnum ]; length = strlen( text ); fwrite( text, sizeof( W8 ), length, fhandle ); fprintf( fhandle, "\n\n" ); MM_FREE( grsegs[ artnum ] ); } fclose( fhandle ); }
/** * \brief Shutdown audio decoder. * \return Nothing. */ PUBLIC void AudioFile_Shutdown( void ) { if( audiohandle ) { fclose( audiohandle ); audiohandle = NULL; } if( audiostarts ) { MM_FREE( audiostarts ); } }
static void agent_vanish(struct sched_state *s) { current_dequeue(s); /* It turns out kernels tend to have vanished threads continue to be the * "current thread" after our trigger point. It's only safe to free them * after somebody else gets scheduled. */ if (s->last_vanished_agent) { assert(!s->last_vanished_agent->action.handling_timer); assert(s->last_vanished_agent->action.context_switch); MM_FREE(s->last_vanished_agent); } s->last_vanished_agent = s->cur_agent; s->num_agents--; }
/* ----------------------------------------------------------------------------- Function: CAL_ShutdownAudioFile() -Decode and save audio data. Parameters: Nothing. Returns: Nothing. Notes: ----------------------------------------------------------------------------- */ PRIVATE void CAL_ShutdownAudioFile() { if( audiohandle ) { fclose( audiohandle ); audiohandle = NULL; } if( audiostarts ) { MM_FREE( audiostarts ); } }
/* ----------------------------------------------------------------------------- Function: Parameters: Returns: Notes: ----------------------------------------------------------------------------- */ PRIVATE void R_ScreenShot_f( void ) { W8 *buffer; char picname[ 80 ]; char checkname[ MAX_OSPATH ]; int i; FILE *f; // create the scrnshots directory if it doesn't exist my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot", FS_Gamedir() ); FS_CreateDirectory( checkname ); // // find a file name to save it to // my_strlcpy( picname, "scrn00.tga", sizeof( picname ) ); for( i = 0 ; i <= 99 ; ++i ) { picname[ 4 ] = i / 10 + '0'; picname[ 5 ] = i % 10 + '0'; my_snprintf( checkname, sizeof( checkname ), "%s/scrnshot/%s", FS_Gamedir(), picname ); f = fopen( checkname, "rb" ); if( ! f ) { break; // file doesn't exist } fclose( f ); } if( i == 100 ) { Com_Printf( "R_ScreenShot_f: Couldn't create a file\n" ); return; } buffer = MM_MALLOC( viddef.width * viddef.height * 3 ); pfglReadPixels( 0, 0, viddef.width, viddef.height, GL_RGB, GL_UNSIGNED_BYTE, buffer ); WriteTGA( checkname, 24, viddef.width, viddef.height, buffer, 1, 1 ); MM_FREE( buffer ); Com_Printf( "Wrote %s\n", picname ); }
/** * @brief Allocates memory for the exponential linear interpolation table. */ void VectorizedSolver::initializeExpEvaluator() { CPUSolver::initializeExpEvaluator(); /* Deallocates memory for the exponentials if it was allocated for a * previous simulation */ if (_thread_exponentials != NULL) MM_FREE(_thread_exponentials); /* Allocates memory for an array of exponential values for each thread * - this is not used by default, but can be to allow for vectorized * evaluation of the exponentials. Unfortunately this does not appear * to give any performance boost. */ int size = _num_threads * _polar_times_groups * sizeof(FP_PRECISION); _thread_exponentials = (FP_PRECISION*)MM_MALLOC(size, VEC_ALIGNMENT); }
bool arbiter_pop_choice(struct arbiter_state *r, unsigned int *tid, bool *txn, unsigned int *xabort_code, struct abort_set *aborts) { struct choice *c = Q_GET_TAIL(&r->choices); if (c) { lsprintf(DEV, "using requested tid %d\n", c->tid); Q_REMOVE(&r->choices, c, nobe); *tid = c->tid; *txn = c->txn; *xabort_code = c->xabort_code; *aborts = c->aborts; MM_FREE(c); return true; } else { return false; } }
/* ----------------------------------------------------------------------------- Function: CA_CacheGrChunk() -Cache graphic chunk. Parameters: chunk -[in] Chunk number to cache. version -[in] extension version. 1 -WL6 2 -SOD Returns: Nothing. Notes: Makes sure a given chunk is in memory, loading it if needed. ----------------------------------------------------------------------------- */ PRIVATE void CA_CacheGrChunk( W32 chunk, W16 version ) { SW32 pos; W32 compressed; void *buffer; W32 next; if( grsegs[ chunk ] ) { return; // already in memory } // // load the chunk into a buffer // pos = GRFILEPOS( chunk ); if( pos < 0 ) // $FFFFFFFF start is a sparse tile { return; } next = chunk + 1; while( GRFILEPOS( next ) == -1 ) // skip past any sparse tiles { next++; } compressed = GRFILEPOS( next ) - pos; fseek( grhandle, pos, SEEK_SET ); buffer = MM_MALLOC( compressed ); if( buffer == NULL ) { return; } fread( buffer, 1, compressed, grhandle ); CAL_ExpandGrChunk( chunk, buffer, version ); MM_FREE( buffer ); }
/** * \brief Cache audio data. * \param[in] chunkId Id of chunk to cache. * \return On success pointer to raw data, otherwise NULL. */ PUBLIC void *AudioFile_CacheAudioChunk( const W32 chunkId ) { W32 pos; W32 chunk_size; W32 count; /* Number of bytes read from file */ SW8 *buffer; // // Load the chunk into a buffer // pos = LittleLong( audiostarts[ chunkId ] ); chunk_size = (LittleLong( audiostarts[ chunkId+1 ] )) - pos; if( chunk_size < 1 ) { fprintf( stderr, "[AudioFile_CacheAudioChunk]: Chunk size not valid\n" ); return NULL; } if( fseek( audiohandle, pos, SEEK_SET ) != 0 ) { fprintf( stderr, "[AudioFile_CacheAudioChunk]: Could not seek in file!\n" ); return NULL; } buffer = (PSW8) MM_MALLOC( chunk_size ); if( buffer == NULL ) { return NULL; } count = fread( buffer, 1, chunk_size, audiohandle ); if( count != chunk_size ) { fprintf( stderr, "[AudioFile_CacheAudioChunk]: Read error!\n" ); MM_FREE( buffer ); return NULL; } return (void *)buffer; }
/** * @brief Destructor deletes Track boundary angular flux and * and FSR scalar flux and source arrays. */ VectorizedSolver::~VectorizedSolver() { if (_boundary_flux != NULL) { MM_FREE(_boundary_flux); _boundary_flux = NULL; } if (_scalar_flux != NULL && !_user_fluxes) { MM_FREE(_scalar_flux); _scalar_flux = NULL; } if (_old_scalar_flux != NULL) { MM_FREE(_old_scalar_flux); _old_scalar_flux = NULL; } if (_reduced_sources != NULL) { MM_FREE(_reduced_sources); _reduced_sources = NULL; } if (_fixed_sources != NULL) { MM_FREE(_fixed_sources); _fixed_sources = NULL; } if (_delta_psi != NULL) { MM_FREE(_delta_psi); _delta_psi = NULL; } if (_thread_taus != NULL) { MM_FREE(_thread_taus); _thread_taus = NULL; } if (_thread_exponentials != NULL) { MM_FREE(_thread_exponentials); _thread_exponentials = NULL; } }