static void destroyCoherentGW( CoherentGW *waveform ) { if ( waveform->h ) { XLALDestroyREAL4VectorSequence( waveform->h->data ); LALFree( waveform->a ); } if ( waveform->a ) { XLALDestroyREAL4VectorSequence( waveform->a->data ); LALFree( waveform->a ); } if ( waveform->phi ) { XLALDestroyREAL8Vector( waveform->phi->data ); LALFree( waveform->phi ); } if ( waveform->f ) { XLALDestroyREAL4Vector( waveform->f->data ); LALFree( waveform->f ); } if ( waveform->shift ) { XLALDestroyREAL4Vector( waveform->shift->data ); LALFree( waveform->shift ); } return; }
static void eos_free_piecewise_polytrope(LALSimNeutronStarEOS * eos) { if (eos) { LALFree(eos->data.piecewisePolytrope); LALFree(eos); } }
int Freemem(void) { LALFree(po); LALFree(p); LALCheckMemoryLeaks(); return 0; }
/** Get rid of a DetectorStateSeries */ void XLALDestroyDetectorStateSeries ( DetectorStateSeries *detStates ) { if ( !detStates ) return; if ( detStates->data ) LALFree ( detStates->data ); LALFree ( detStates ); return; } /* XLALDestroyDetectorStateSeries() */
/* sets up a FstatCheckpointFile from parameters */ int fstat_cpt_file_create (FstatCheckpointFile **cptf, CHAR *filename, UINT4 bufsize, UINT4 maxsize, toplist_t*list) { /* input sanity checks */ if ( (cptf == NULL) || (*cptf != NULL) || (list == NULL) || (filename == NULL) || (strlen (filename) == 0) ) { LogPrintf (LOG_CRITICAL, "ERROR: error in input parameters (fstat_cpt_file_create)\n"); return(-1); } /* allocation */ *cptf = LALMalloc(sizeof(FstatCheckpointFile)); if (!(*cptf)) { LogPrintf (LOG_CRITICAL, "ERROR: out of memeory (fstat_cpt_file_create)\n"); return(-1); } (*cptf)->filename = LALMalloc(strlen(filename)+1); if (!((*cptf)->filename)) { LogPrintf (LOG_CRITICAL, "ERROR: out of memeory (fstat_cpt_file_create)\n"); LALFree(*cptf); *cptf = NULL; return(-1); } if (bufsize > 0) { (*cptf)->buffer = LALMalloc(bufsize); if (!((*cptf)->buffer)) { LogPrintf (LOG_CRITICAL, "ERROR: out of memeory (fstat_cpt_file_create)\n"); LALFree(*cptf); LALFree((*cptf)->filename); *cptf = NULL; return(-1); } } /* initialization */ strncpy((*cptf)->filename,filename,strlen(filename)+1); (*cptf)->bytes = 0; (*cptf)->bufsize = bufsize; (*cptf)->maxsize = maxsize; (*cptf)->checksum = 0; (*cptf)->fp = NULL; (*cptf)->list = list; return(0); }
/* destroys a FstatCheckpointFile structure */ int fstat_cpt_file_destroy (FstatCheckpointFile **cptf) { if (!cptf) { LogPrintf (LOG_CRITICAL, "ERROR: FstatCheckpointFile is NULL\n"); return(-1); } if((*cptf)->filename) LALFree((*cptf)->filename); if((*cptf)->buffer) LALFree((*cptf)->buffer); LALFree(*cptf); *cptf = NULL; return(0); }
int FreeMem(void) { if (SSparams->numSpinDown>0) { for(i=0;i<SSparams->numSTKs;i++) { LALFree(pTdotsAndDeltaTs->vecDeltaTs[i]); } LALFree(pTdotsAndDeltaTs->vecDeltaTs); } LALFree(pTdotsAndDeltaTs->vecTDots); LALFree(pTdotsAndDeltaTs); for (i=0; i<7 ; i++) { LALFree(fakeSFT[i]); } LALFree(fakeSFT); LALFree(SSparams); LALFree(params); return 0; }
ATYPE * XFUNC ( UINT4Vector *dimLength ) { ATYPE *arr; UINT4 size = 1; UINT4 ndim; UINT4 dim; if ( ! dimLength ) XLAL_ERROR_NULL( XLAL_EFAULT ); if ( ! dimLength->length ) XLAL_ERROR_NULL( XLAL_EBADLEN ); if ( ! dimLength->data ) XLAL_ERROR_NULL( XLAL_EINVAL ); ndim = dimLength->length; for ( dim = 0; dim < ndim; ++dim ) size *= dimLength->data[dim]; if ( ! size ) XLAL_ERROR_NULL( XLAL_EBADLEN ); /* create array */ arr = LALMalloc( sizeof( *arr ) ); if ( ! arr ) XLAL_ERROR_NULL( XLAL_ENOMEM ); /* create array dimensions */ arr->dimLength = XLALCreateUINT4Vector( ndim ); if ( ! arr->dimLength ) { LALFree( arr ); XLAL_ERROR_NULL( XLAL_EFUNC ); } /* copy dimension lengths */ memcpy( arr->dimLength->data, dimLength->data, ndim * sizeof( *arr->dimLength->data ) ); /* allocate data storage */ arr->data = LALMalloc( size * sizeof( *arr->data ) ); if ( ! arr->data ) { XLALDestroyUINT4Vector( arr->dimLength ); LALFree( arr ); XLAL_ERROR_NULL( XLAL_ENOMEM ); } return arr; }
/** Main driver funtion for doing Numerical Relativity Injections */ void LALDriveNRInject( LALStatus *status, /**< pointer to LALStatus structure */ REAL4TimeSeries *injData, /**< The time series to inject into */ SimInspiralTable *injections, /**< The list of injections to perform */ NumRelInjectParams *params /**< Parameters */ ) { REAL4TimeVectorSeries *sumStrain = NULL; SimInspiralTable *thisInj = NULL; /* current injection */ INITSTATUS(status); ATTATCHSTATUSPTR (status); /* loop over injections */ for ( thisInj = injections; thisInj; thisInj = thisInj->next ) { TRY( LALAddStrainModes(status->statusPtr, &sumStrain, params->nrCatalog, params->modeLlo, params->modeLhi, thisInj), status); TRY( LALInjectStrainGW( status->statusPtr, injData, sumStrain, thisInj, params->ifo, params->dynRange), status); XLALDestroyREAL4VectorSequence ( sumStrain->data ); LALFree( sumStrain ); sumStrain = NULL; } /* end loop over injections */ DETATCHSTATUSPTR(status); RETURN(status); }
STYPE * XFUNC ( UINT4 length, UINT4 veclen ) { STYPE *seq; if ( ! length || ! veclen ) XLAL_ERROR_NULL( XLAL_EBADLEN ); seq = LALMalloc( sizeof( *seq ) ); if ( ! seq ) XLAL_ERROR_NULL( XLAL_ENOMEM ); seq->length = length; seq->vectorLength = veclen; if ( ! length || ! veclen ) seq->data = NULL; else { seq->data = LALMalloc( length * veclen * sizeof( *seq->data ) ); if ( ! seq ) { LALFree( seq ); XLAL_ERROR_NULL( XLAL_ENOMEM ); } } return seq; }
REAL8 calculate_ligo_snr_from_strain( REAL4TimeVectorSeries *strain, SimInspiralTable *thisInj, const CHAR ifo[3]) { REAL8 ret = -1, snrSq, freq, psdValue; REAL8 sampleRate = 4096, deltaF; REAL4TimeSeries *chan = NULL; REAL4FFTPlan *pfwd; COMPLEX8FrequencySeries *fftData; UINT4 k; /* create the time series */ chan = XLALCalculateNRStrain( strain, thisInj, ifo, sampleRate ); deltaF = chan->deltaT * strain->data->vectorLength; fftData = XLALCreateCOMPLEX8FrequencySeries( chan->name, &(chan->epoch), 0, deltaF, &lalDimensionlessUnit, chan->data->length/2 + 1 ); /* perform the fft */ pfwd = XLALCreateForwardREAL4FFTPlan( chan->data->length, 0 ); XLALREAL4TimeFreqFFT( fftData, chan, pfwd ); /* compute the SNR for initial LIGO at design */ for ( snrSq = 0, k = 0; k < fftData->data->length; k++ ) { freq = fftData->deltaF * k; if ( ifo[0] == 'V' ) { if (freq < 35) continue; LALVIRGOPsd( NULL, &psdValue, freq ); psdValue /= 9e-46; } else { if (freq < 40) continue; LALLIGOIPsd( NULL, &psdValue, freq ); } fftData->data->data[k] /= 3e-23; snrSq += crealf(fftData->data->data[k]) * crealf(fftData->data->data[k]) / psdValue; snrSq += cimagf(fftData->data->data[k]) * cimagf(fftData->data->data[k]) / psdValue; } snrSq *= 4*fftData->deltaF; XLALDestroyREAL4FFTPlan( pfwd ); XLALDestroyCOMPLEX8FrequencySeries( fftData ); XLALDestroyREAL4Vector ( chan->data); LALFree(chan); ret = sqrt(snrSq); return ret; }
static REAL8VectorList * XLALREAL8VectorListAddEntry (REAL8VectorList *head, const REAL8Vector *entry) { UINT4 dim; REAL8VectorList *ptr = NULL; /* running list-pointer */ REAL8VectorList *newElement = NULL; /* new list-element */ /* check illegal input */ if ( (head == NULL) || (entry == NULL) ) return NULL; /* find tail of list */ ptr = head; while ( ptr->next ) ptr = ptr->next; /* construct new list-element */ dim = entry->length; if ( (newElement = LALCalloc (1, sizeof (*newElement))) == NULL) return NULL; if ( (newElement->entry.data = LALCalloc (dim, sizeof(entry->data[0]))) == NULL ) { LALFree (newElement); return NULL; } newElement->entry.length = dim; memcpy (newElement->entry.data, entry->data, dim * sizeof(entry->data[0]) ); /* link this to the tail of list */ ptr->next = newElement; newElement->prev = ptr; return newElement; } /* XLALREAL8VectorListAddEntry() */
void FUNC ( LALStatus *status, STYPE **aseq ) { /* * Initialize status */ INITSTATUS(status); ATTATCHSTATUSPTR( status ); /* * Check aseq: is it non-NULL? */ ASSERT (aseq != NULL, status, SEQFACTORIESH_EVPTR, SEQFACTORIESH_MSGEVPTR); /* * Check aseq: does it point to non-NULL? */ ASSERT (*aseq != NULL,status, SEQFACTORIESH_EUPTR, SEQFACTORIESH_MSGEUPTR); /* * Check dimLength in aseq: does it point to non-NULL? */ ASSERT ((*aseq)->dimLength != NULL, status, SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR); /* * Check data in aseq: does it point to non-NULL? */ ASSERT ((*aseq)->data != NULL, status, SEQFACTORIESH_EDPTR, SEQFACTORIESH_MSGEDPTR); /* Ok, now let's free allocated storage */ TRY( LALU4DestroyVector( status->statusPtr, &((*aseq)->dimLength) ), status ); LALFree ( (*aseq)->data ); /* free allocated data */ LALFree ( *aseq ); /* free aseq struct itself */ *aseq = NULL; /* make sure we don't point to freed struct */ DETATCHSTATUSPTR( status ); RETURN (status); }
/* test to make sure padding does what it's supposed to do */ static int testPadding( void ) { int keep = lalDebugLevel; XLALClobberDebugLevel(lalDebugLevel | LALMEMDBGBIT | LALMEMPADBIT); XLALClobberDebugLevel(lalDebugLevel & ~LALMEMTRKBIT); /* try to free NULL pointer */ /* changed behaviour: LALFree is a no-op when passed NULL */ // trial( LALFree( NULL ), SIGSEGV, "error: tried to free NULL pointer" ); /* double free */ /* actually, this cannot be done robustly -- system can change values * in unallocated space at will */ //trial( p = LALMalloc( 2 * sizeof( *p ) ), 0, "" ); //trial( LALFree( p ), 0, "" ); //trial( LALFree( p ), SIGSEGV, "error: tried to free a freed pointer" ); //trial( LALCheckMemoryLeaks(), 0, "" ); /* wrong magic */ trial( p = LALMalloc( 2 * sizeof( *p ) ), 0, "" ); p[-1] = 4; trial( LALFree( p ), SIGSEGV, "error: wrong magic" ); p[-1] = 0xABadCafe; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* corrupt size */ trial( p = LALMalloc( 4 * sizeof( *p ) ), 0, ""); n = p[-2]; p[-2] = -2; trial( LALFree( p ), SIGSEGV, "error: corrupt size descriptor" ); p[-2] = n; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* overwritten array bounds */ trial( p = LALMalloc( 8 * sizeof( *p ) ), 0, "" ); n = p[8]; p[8] = 0; trial( LALFree( p ), SIGSEGV, "error: array bounds overwritten" ); p[8] = n; trial( LALFree( p ), 0, "" ); trial( LALCheckMemoryLeaks(), 0, "" ); /* free too much memory */ q = malloc( 4 * sizeof( *p ) ); trial( p = LALMalloc( sizeof( *p ) ), 0, "" ); memcpy( q, p - 2, 4 * sizeof( *p ) ); trial( LALFree( p ), 0, "" ); trial( LALFree( q + 2 ), SIGSEGV, "error: lalMallocTotal too small" ); free( q ); trial( LALCheckMemoryLeaks(), 0, "" ); XLALClobberDebugLevel(keep); return 0; }
/** * top level function to remove lines from a multi sft vector given a list of files * containing list of known spectral lines */ void LALRemoveKnownLinesInMultiSFTVector (LALStatus *status, /**< pointer to LALStatus structure */ MultiSFTVector *MultiSFTVect, /**< SFTVector to be cleaned */ INT4 width, /**< maximum width to be cleaned */ INT4 window, /**< window size for noise floor estimation in vicinity of a line */ LALStringVector *linefiles, /**< file with list of lines */ RandomParams *randPar) /**< for creating random numbers */ { UINT4 k, j, numifos; CHAR *ifo; INITSTATUS(status); ATTATCHSTATUSPTR (status); ASSERT (MultiSFTVect, status, SFTCLEANH_ENULL, SFTCLEANH_MSGENULL); ASSERT (MultiSFTVect->data, status, SFTCLEANH_ENULL, SFTCLEANH_MSGENULL); ASSERT (MultiSFTVect->length > 0, status, SFTCLEANH_EVAL, SFTCLEANH_MSGEVAL); ASSERT (width > 0, status, SFTCLEANH_EVAL, SFTCLEANH_MSGEVAL); ASSERT (window > 0, status, SFTCLEANH_EVAL, SFTCLEANH_MSGEVAL); numifos = MultiSFTVect->length; if ( linefiles != NULL ) { ASSERT (linefiles->length > 0, status, SFTCLEANH_EVAL, SFTCLEANH_MSGEVAL); ASSERT (linefiles->data, status, SFTCLEANH_ENULL, SFTCLEANH_MSGENULL); /* loop over linefiles and clean the relevant SFTs */ for ( k = 0; k < linefiles->length; k++) { ifo = NULL; /* try to get the ifo name from the linefile name */ if ( (ifo = XLALGetChannelPrefix ( linefiles->data[k])) == NULL) { ABORT ( status, SFTCLEANH_ELINENAME, SFTCLEANH_MSGELINENAME); } /* loop over ifos and see if any matches */ for ( j = 0; j < numifos; j++) { if ( strncmp( ifo, MultiSFTVect->data[j]->data->name, 3) == 0) { /* clean the sftvector which has matched */ TRY ( LALRemoveKnownLinesInSFTVect ( status->statusPtr, MultiSFTVect->data[j], width, window, linefiles->data[k], randPar), status); } } /* loop over ifos */ LALFree( ifo ); } /* loop over linefiles */ } /* if linefiles != NULL */ DETATCHSTATUSPTR (status); /* normal exit */ RETURN (status); }
static void eos_free_tabular(LALSimNeutronStarEOS * eos) { if (eos) { eos_free_tabular_data(eos->data.tabular); LALFree(eos); } return; }
void gnuplot_output_fs(const char *fname, const char *fmt, REAL8FrequencySeries *series) { LALUnit asdunit; char *units; size_t i; FILE *gp = popen("gnuplot -persistent", "w"); if (!gp) { fprintf(stderr, "require program gnuplot to output .%s files", fmt); exit(1); } /* get the sample units as a string */ XLALUnitSqrt(&asdunit, &series->sampleUnits); units = XLALUnitToString(&asdunit); if (units == NULL || *units == '\0') { LALFree(units); units = XLALStringDuplicate("unknown units"); } /* modify fmt as required by gnuplot */ if (strcmp(fmt, "jpg") == 0) fmt = "jpeg"; else if (strcmp(fmt, "ps") == 0) fmt = "postscript landscape"; else if (strcmp(fmt, "eps") == 0) fmt = "postscript eps"; /* issue gnuplot commands */ fprintf(gp, "set terminal %s\n", fmt); fprintf(gp, "set output '%s'\n", fname); fprintf(gp, "set key off\n"); fprintf(gp, "set grid xtics mxtics ytics\n"); fprintf(gp, "set xlabel 'frequency (Hz)'\n"); fprintf(gp, "set ylabel 'amplitude spectral density (%s)'\n", units); fprintf(gp, "set title '%s @ %d.%09d\n", series->name, series->epoch.gpsSeconds, series->epoch.gpsNanoSeconds); fprintf(gp, "set logscale\n"); fprintf(gp, "plot '-' with lines\n"); for (i = 0; i < series->data->length; ++i) fprintf(gp, "%.9f\t%e\n", series->f0 + i * series->deltaF, sqrt(series->data->data[i])); fprintf(gp, "e"); pclose(gp); LALFree(units); return; }
void CStaticResourcePool::Free(DWORD dwResourceHandle) { STATIC_RESOURCE_ITEM* pItem = (STATIC_RESOURCE_ITEM*)dwResourceHandle; *pItem->pbEnable = FALSE; m_pFreeFunc(pItem->pVoid); UnLinkFromSortLink(&m_pSortLinkHead,&m_pSortLinkTail,&pItem->sortLink); LALFree(m_pItemPool,pItem); }
void XLALFrameUFrDetectorFree_FrameL_(LALFrameUFrDetector * detector) { if (detector) { FrDetectorFree(detector->handle); LALFree(detector); } return; }
/** * @brief Closes a LALFrStream * @details * This routine closes all file pointers and deallocates memory associated * with a given #LALFrStream. It performs no action if @p stream is NULL. * @param stream Pointer to the #LALFrStream structure to be closed. * @retval 0 Success. * @retval <0 Failure. */ int XLALFrStreamClose(LALFrStream * stream) { if (stream) { XLALDestroyCache(stream->cache); XLALFrStreamFileClose(stream); LALFree(stream); } return 0; }
int FUNC(VECTORTYPE *vector, FILTERTYPE *filter) { INT4 j; /* Index for filter coeficients. */ INT4 length; /* Length of vector. */ DATATYPE *data; /* Vector data. */ DBLDATATYPE w, datum; /* Current auxiliary and output values. */ INT4 directOrder; /* Number of direct filter coefficients. */ INT4 recursOrder; /* Number of recursive filter coefficients. */ INT4 numHist; /* The number of auxiliary data kept. */ REAL8 *directCoef; /* Direct filter coefficients. */ REAL8 *recursCoef; /* Recursive filter coefficients. */ DBLDATATYPE *temp=NULL; /* Temporary storage for auxiliary sequence. */ /* Make sure all the structures have been initialized. */ if ( ! vector || ! filter ) XLAL_ERROR( XLAL_EFAULT ); if ( ! vector->data ) XLAL_ERROR( XLAL_EINVAL ); if ( ! filter->directCoef || ! filter->recursCoef || ! filter->history || ! filter->directCoef->data || ! filter->recursCoef->data || ! filter->history->data ) XLAL_ERROR( XLAL_EINVAL ); length=vector->length; data=vector->data+length-1; directOrder=filter->directCoef->length; recursOrder=filter->recursCoef->length; directCoef=filter->directCoef->data; recursCoef=filter->recursCoef->data; numHist=filter->history->length+1; temp = LALMalloc( numHist*sizeof(*temp) ); if ( ! temp ) XLAL_ERROR( XLAL_ENOMEM ); memset(temp,0,(numHist-1)*sizeof(*temp)); /* Run through the vector. */ while(length--){ /* Compute the auxiliary variable. */ for(j=numHist-1;j>=recursOrder;j--) temp[j]=temp[j-1]; w=*data; for(;j;j--) w+=recursCoef[j]*(temp[j]=temp[j-1]); /* Compute filter output. */ datum=*directCoef*(*temp=w); for(j=1;j<directOrder;j++) datum+=directCoef[j]*temp[j]; *(data--)=datum; } LALFree(temp); /* Normal exit */ return 0; }
int XLALFreeSimRingdown ( SimRingdownTable **eventHead ) { EventIDColumn *eventId; while ( (*eventHead)->event_id ) { /* free any associated event_id's */ eventId = (*eventHead)->event_id; (*eventHead)->event_id = (*eventHead)->event_id->next; LALFree( eventId ); } LALFree( *eventHead ); return (0); }
void XLALFrameUFrFileClose_FrameL_(LALFrameUFrFile * stream) { if (stream) { if (stream->mode == XLAL_FRAMEU_FR_FILE_MODE_R) FrFileIEnd(stream->handle); else FrFileOEnd(stream->handle); LALFree(stream); } }
static void eos_free_tabular_data(LALSimNeutronStarEOSDataTabular * data) { if (data) { gsl_interp_free(data->e_of_p_interp); gsl_interp_free(data->e_of_h_interp); gsl_interp_free(data->p_of_h_interp); gsl_interp_free(data->h_of_p_interp); gsl_interp_free(data->rho_of_h_interp); gsl_interp_accel_free(data->e_of_p_acc); gsl_interp_accel_free(data->e_of_h_acc); gsl_interp_accel_free(data->p_of_h_acc); gsl_interp_accel_free(data->h_of_p_acc); gsl_interp_accel_free(data->rho_of_h_acc); LALFree(data->edat); LALFree(data->pdat); LALFree(data->hdat); LALFree(data->rhodat); LALFree(data); } return; }
/** * Destroy a MultiAMCoeffs structure. * * Note, this is "NULL-robust" in the sense that it will not crash * on NULL-entries anywhere in this struct, so it can be used * for failure-cleanup even on incomplete structs */ void XLALDestroyMultiAMCoeffs ( MultiAMCoeffs *multiAMcoef ) { UINT4 X; if ( ! multiAMcoef ) return; if ( multiAMcoef->data ) { for ( X=0; X < multiAMcoef->length; X ++ ) { XLALDestroyAMCoeffs ( multiAMcoef->data[X] ); } /* for X < numDetectors */ LALFree ( multiAMcoef->data ); } LALFree ( multiAMcoef ); return; } /* XLALDestroyMultiAMCoeffs() */
int clear_status( LALStatus *stat ) { if ( ! stat ) return 1; while ( stat->statusPtr ) { LALStatus *next = stat->statusPtr->statusPtr; LALFree( stat->statusPtr ); stat->statusPtr = next; } memset( stat, 0, sizeof( *stat ) ); return 0; }
/** * Helper function to get rid of a multi-IFO DetectorStateSeries * Note, this is "NULL-robust" in the sense that it will not crash * on NULL-entries anywhere in this struct, so it can be used * for failure-cleanup even on incomplete structs. */ void XLALDestroyMultiDetectorStateSeries ( MultiDetectorStateSeries *mdetStates ) { UINT4 X, numDet; if ( !mdetStates ) return; numDet = mdetStates->length; if ( mdetStates->data ) { for ( X=0; X < numDet ; X ++ ) XLALDestroyDetectorStateSeries ( mdetStates->data[X] ); LALFree ( mdetStates->data ); } LALFree ( mdetStates ); return; } /* XLALDestroyMultiDetectorStateSeries() */
/* helper function to create new channel of appropriate type */ static LALFrameUFrChan *XLALFrameUFrChanAlloc(const char *name, int chanType, int dataType, size_t ndata) { LALFrameUFrChan *channel; channel = LALCalloc(1, sizeof(*channel)); if (!channel) XLAL_ERROR_NULL(XLAL_ENOMEM); channel->type = chanType; switch (chanType) { case XLAL_FRAMEU_FR_CHAN_TYPE_ADC: channel->handle.adc = XLALFrameUFrAdcDataNew(name, dataType); if (!channel->handle.adc) { LALFree(channel); XLAL_ERROR_NULL(XLAL_EFUNC); } break; case XLAL_FRAMEU_FR_CHAN_TYPE_SIM: channel->handle.sim = XLALFrameUFrSimDataNew(name); if (!channel->handle.sim) { LALFree(channel); XLAL_ERROR_NULL(XLAL_EFUNC); } break; case XLAL_FRAMEU_FR_CHAN_TYPE_PROC: channel->handle.proc = XLALFrameUFrProcDataNew(name); if (!channel->handle.proc) { LALFree(channel); XLAL_ERROR_NULL(XLAL_EFUNC); } break; default: /* unrecognized channel type */ LALFree(channel); XLAL_ERROR_NULL(XLAL_ETYPE); } if (XLALFrameUFrChanVectorAlloc(channel, dataType, ndata) < 0) { XLALFrameUFrChanFree(channel); XLAL_ERROR_NULL(XLAL_EFUNC); } return channel; }
/* Try to free up memory. */ static void cleanup( LALStatus *s, REAL4Array **m, UINT4Vector **md, REAL4Vector **e, SnglInspiralTable *f, SnglInspiralTable *t, INT4 *nt) { INITSTATUS(s); ATTATCHSTATUSPTR( s ); if (m){ TRY(LALU4DestroyVector(s->statusPtr,md),s); } if (md){ TRY(LALSDestroyVector(s->statusPtr, e),s); } if (e){ TRY(LALSDestroyArray(s->statusPtr, m),s); } if (t && f) { t = f; while ((t->next) && (*nt > 0)) { f = t; t = t->next; LALFree(f); --(*nt); }/* while(tmplt) */ LALFree(t); --(*nt); } DETATCHSTATUSPTR( s ); RETURN( s ); }
static void XLALREAL8VectorListDestroy (REAL8VectorList *head) { REAL8VectorList *ptr, *next; if ( !head ) return; next = head; do { /* step to next element */ ptr = next; /* remember pointer to next element */ next = ptr->next; /* free current element */ LALFree (ptr->entry.data); LALFree (ptr); } while ( (ptr = next) != NULL ); return; } /* XLALREAL8VectorListDestroy() */