本文整理汇总了C++中LALCheckMemoryLeaks函数的典型用法代码示例。如果您正苦于以下问题:C++ LALCheckMemoryLeaks函数的具体用法?C++ LALCheckMemoryLeaks怎么用?C++ LALCheckMemoryLeaks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LALCheckMemoryLeaks函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testPadding
/* 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;
}
示例2: main
/*---------- function definitions ---------- */
int main(int argc,char *argv[])
{
LALStatus status = blank_status; /* initialize status */
vrbflg = 1; /* verbose error-messages */
/* set LAL error-handler */
lal_errhandler = LAL_ERR_EXIT; /* exit with returned status-code on error */
/* register all user-variables */
LAL_CALL (InitUserVars(&status, &CommandLineArgs), &status);
/* read cmdline & cfgfile */
BOOLEAN should_exit = 0;
XLAL_CHECK_MAIN (XLALUserVarReadAllInput(&should_exit, argc, argv, lalAppsVCSInfoList) == XLAL_SUCCESS, XLAL_EFUNC);
if (should_exit)
return EXIT_FAILURE;
LAL_CALL ( CheckUserInput (&status, &CommandLineArgs), &status);
LAL_CALL ( Initialize (&status, &CommandLineArgs), &status);
/*---------- central function: compute F-statistic ---------- */
LAL_CALL ( ComputeF(&status, CommandLineArgs), &status);
/* Free remaining memory */
LAL_CALL ( LALSDestroyVector(&status, &(amc.a) ), &status);
LAL_CALL ( LALSDestroyVector(&status, &(amc.b) ), &status);
XLALDestroyUserVars();
LALCheckMemoryLeaks();
return 0;
} /* main() */
示例3: main
int main( int argc, char *argv[] )
{
LALFILE *outfile = NULL;
LALCache *cache;
int arg = 1;
XLALSetErrorHandler( XLALExitErrorHandler );
if ( argc > 1 && ! strcmp(argv[1],"-o") ) {
outfile = XLALFileOpen( argv[2], "w" );
arg += 2;
}
cache = XLALCacheGlob( NULL, argc == 1 ? NULL : argv[arg] );
for ( ; arg < argc; ++arg ) {
LALCache *tmp = cache;
LALCache *add;
add = XLALCacheGlob( NULL, argv[arg] );
cache = XLALCacheMerge( tmp, add );
XLALDestroyCache( add );
XLALDestroyCache( tmp );
}
XLALCacheFileWrite( outfile ? outfile : LALSTDOUT, cache );
XLALFileClose( outfile );
XLALDestroyCache( cache );
LALCheckMemoryLeaks();
return 0;
}
示例4: main
/* ********************************************************/
int main(int UNUSED argc, char **argv)
{
static LALStatus status; /* status structure */
/* initialize status */
status.statusCode = 0;
status.statusPtr = NULL;
status.statusDescription = NULL;
/* Actual test are performed by this function */
/* RunGeneratePulsarSignalTest(&status,argc,argv); */ /* 02/02/05 gam */
RunGeneratePulsarSignalTest(&status);
if (status.statusCode) {
fprintf(stderr,"Error: statusCode = %i statusDescription = %s \n", status.statusCode, status.statusDescription);
return 1;
}
LALCheckMemoryLeaks();
if ( lalDebugLevel & LALINFO ) {
XLALPrintError( "Info[0]: program %s, file %s, line %d, %s\n"
" %s\n", *argv, __FILE__, __LINE__,
"$Id$", (GENERATEPULSARSIGNALTESTC_MSGENORM) );
}
return GENERATEPULSARSIGNALTESTC_ENORM;
}
示例5: main
int main( void )
{
#if defined(NDEBUG) /* debugging is turned off */
return 77; /* don't do any testing */
#else
XLALGetDebugLevel();
XLALClobberDebugLevel(LALMEMDBG);
/* get rid of annoying messages from elsewhere */
setvbuf( mystderr = stdout, NULL, _IONBF, 0 );
FILE *fp = freopen( "/dev/null", "w", stderr );
if (fp == NULL) die ( unable to open /dev/null );
lalRaiseHook = TestRaise;
if ( lalNoDebug ) /* library was not compiled with debugging */
return 77; /* don't do any testing */
if ( testOK() ) return 1;
if ( testPadding() ) return 1;
if ( testAllocList() ) return 1;
if ( stressTestRealloc() ) return 1;
trial( LALCheckMemoryLeaks(), 0, "" );
return 0;
#endif
}
示例6: main
int main( void )
{
CircularOrbit();
EccentricOrbit();
LALCheckMemoryLeaks();
return 0;
}
示例7: main
int main(void)
{
XLALSetErrorHandler(XLALAbortErrorHandler);
test_orf();
LALCheckMemoryLeaks();
return 0;
}
示例8: main
int main(int argc, char *argv[])
{
char tstr[32]; // string to hold GPS time -- 31 characters is enough
const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds
const size_t length = 65536; // number of points in a segment
const size_t stride = length / 2; // number of points in a stride
size_t i, n;
REAL8FrequencySeries *OmegaGW = NULL;
REAL8TimeSeries **seg = NULL;
LIGOTimeGPS epoch;
gsl_rng *rng;
XLALSetErrorHandler(XLALAbortErrorHandler);
parseargs(argc, argv);
XLALGPSSetREAL8(&epoch, tstart);
gsl_rng_env_setup();
rng = gsl_rng_alloc(gsl_rng_default);
OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1);
n = duration * srate;
seg = LALCalloc(numDetectors, sizeof(*seg));
printf("# time (s)");
for (i = 0; i < numDetectors; ++i) {
char name[LALNameLength];
snprintf(name, sizeof(name), "%s:STRAIN", detectors[i].frDetector.prefix);
seg[i] = XLALCreateREAL8TimeSeries(name, &epoch, 0.0, 1.0/srate, &lalStrainUnit, length);
printf("\t%s (strain)", name);
}
printf("\n");
XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize
while (1) { // infinite loop
size_t j;
for (j = 0; j < stride; ++j, --n) { // output first stride points
LIGOTimeGPS t = seg[0]->epoch;
if (n == 0) // check if we're done
goto end;
printf("%s", XLALGPSToStr(tstr, XLALGPSAdd(&t, j * seg[0]->deltaT)));
for (i = 0; i < numDetectors; ++i)
printf("\t%e", seg[i]->data->data[j]);
printf("\n");
}
XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data
}
end:
for (i = 0; i < numDetectors; ++i)
XLALDestroyREAL8TimeSeries(seg[i]);
XLALFree(seg);
XLALDestroyREAL8FrequencySeries(OmegaGW);
LALCheckMemoryLeaks();
return 0;
}
示例9: main
int main( int argc, char *argv[]) {
/* sanity check for input arguments */
if ( argc != 1 )
XLAL_ERROR ( XLAL_EINVAL, "The executable '%s' doesn't support any input arguments right now.\n", argv[0] );
printf ("Starting test...\n");
/* set up single- and multi-IFO F-stat input */
REAL4 TwoF = 7.0;
UINT4 numDetectors = 2;
REAL4Vector *TwoFX = NULL;
if ( (TwoFX = XLALCreateREAL4Vector ( numDetectors )) == NULL ) {
XLAL_ERROR ( XLAL_EFUNC, "failed to XLALCreateREAL4Vector( %d )\n", numDetectors );
return XLAL_EFAILED;
}
TwoFX->data[0] = 4.0;
TwoFX->data[1] = 12.0;
REAL8 rhomaxline = 0.0; /* prior from LV-stat derivation, 0 means pure line veto, +inf means pure multi-Fstat */
REAL8Vector *lX = NULL; /* per-IFO prior odds ratio for line vs. Gaussian noise, NULL is interpreted as l[X]=1 for all X */
/* maximum allowed difference between recalculated and XLAL result */
REAL4 tolerance_allterms = 2e-04;
REAL4 tolerance_leadterm = 2e-02;
/* compute and compare the results for one set of rhomaxline, lX values */
printf ("Computing LV-stat for TwoF_multi=%f, TwoFX[0]=%f, TwoFX[1]=%f, rhomaxline=%f, priors lX=NULL...\n", TwoF, TwoFX->data[0], TwoFX->data[1], rhomaxline );
if ( XLALCompareLVComputations( TwoF, TwoFX, rhomaxline, lX, tolerance_allterms, tolerance_leadterm ) != XLAL_SUCCESS ) {
XLAL_ERROR ( XLAL_EFUNC, "Test failed.\n" );
return XLAL_EFAILED;
}
/* change the priors to catch more possible problems */
rhomaxline = 5.0;
if ( (lX = XLALCreateREAL8Vector ( numDetectors )) == NULL ) {
XLAL_ERROR ( XLAL_EFUNC, "failed to XLALCreateREAL8Vector( %d )\n", numDetectors );
return XLAL_EFAILED;
}
lX->data[0] = 0.5;
lX->data[1] = 0.8;
/* compute and compare the results for second set of rhomaxline, lX values */
printf ("Computing LV-stat for TwoF_multi=%f, TwoFX[0]=%f, TwoFX[1]=%f, rhomaxline=%f, priors lX=(%f,%f)...\n", TwoF, TwoFX->data[0], TwoFX->data[1], rhomaxline, lX->data[0], lX->data[1] );
if ( XLALCompareLVComputations( TwoF, TwoFX, rhomaxline, lX, tolerance_allterms, tolerance_leadterm ) != XLAL_SUCCESS ) {
XLAL_ERROR ( XLAL_EFUNC, "Test failed.\n" );
return XLAL_EFAILED;
}
/* free memory */
XLALDestroyREAL4Vector(TwoFX);
XLALDestroyREAL8Vector(lX);
LALCheckMemoryLeaks();
return XLAL_SUCCESS;
} /* main */
示例10: main
/* ----- function definitions ---------- */
int
main ( void )
{
LALStatus XLAL_INIT_DECL(status);
SFTCatalog *catalog = NULL;
SFTConstraints XLAL_INIT_DECL(constraints);
MultiSFTVector *multiSFTs = NULL;
MultiPSDVector *multiPSDs = NULL;
MultiNoiseWeights *multiWeightsXLAL = NULL;
MultiNoiseWeights *multiWeightsCorrect = NULL;
UINT4 rngmedBins = 11;
REAL8 tolerance = 2e-6; /* same algorithm, should be basically identical results */
/* Construct the "correct" weights, calculated using the old LAL routines */
UINT4 numIFOsCorrect = 2;
XLAL_CHECK ( ( multiWeightsCorrect = XLALCalloc ( 1, sizeof(*multiWeightsCorrect ) ) ) != NULL, XLAL_ENOMEM );
multiWeightsCorrect->length = numIFOsCorrect;
multiWeightsCorrect->Sinv_Tsft = 1.980867126449e+52;
XLAL_CHECK ( ( multiWeightsCorrect->data = XLALCalloc ( numIFOsCorrect, sizeof(*multiWeightsCorrect->data ) ) ) != NULL, XLAL_ENOMEM );
XLAL_CHECK ( ( multiWeightsCorrect->data[0] = XLALCreateREAL8Vector(4) ) != NULL, XLAL_ENOMEM );
multiWeightsCorrect->data[0]->data[0] = 6.425160659487e-05;
multiWeightsCorrect->data[0]->data[1] = 7.259453662367e-06;
multiWeightsCorrect->data[0]->data[2] = 9.838893684664e-04;
multiWeightsCorrect->data[0]->data[3] = 5.043766789923e-05;
XLAL_CHECK ( ( multiWeightsCorrect->data[1] = XLALCreateREAL8Vector(3) ) != NULL, XLAL_ENOMEM );
multiWeightsCorrect->data[1]->data[0] = 1.582309910283e-04;
multiWeightsCorrect->data[1]->data[1] = 5.345673753744e-04;
multiWeightsCorrect->data[1]->data[2] = 6.998201363537e+00;
/* Construct the catalog */
XLAL_CHECK ( ( catalog = XLALSFTdataFind ( TEST_DATA_DIR "MultiNoiseWeightsTest*.sft", &constraints ) ) != NULL, XLAL_EFUNC, " XLALSFTdataFind failed\n" );
/* Load the SFTs */
XLAL_CHECK ( ( multiSFTs = XLALLoadMultiSFTs ( catalog, -1, -1 ) ) != NULL, XLAL_EFUNC, " XLALLoadMultiSFTs failed\n" );
/* calculate the psd and normalize the SFTs */
XLAL_CHECK ( ( multiPSDs = XLALNormalizeMultiSFTVect ( multiSFTs, rngmedBins, NULL ) ) != NULL, XLAL_EFUNC, " XLALNormalizeMultiSFTVect failed\n" );
/* Get weights using XLAL function */
XLAL_CHECK ( ( multiWeightsXLAL = XLALComputeMultiNoiseWeights ( multiPSDs, rngmedBins, 0 ) ) != NULL, XLAL_EFUNC, " XLALComputeMultiNoiseWeights failed\n" );
/* Compare XLAL weights to reference */
XLAL_CHECK ( XLALCompareMultiNoiseWeights ( multiWeightsXLAL, multiWeightsCorrect, tolerance ) == XLAL_SUCCESS, XLAL_EFAILED, "Comparison between XLAL and reference MultiNoiseWeights failed\n" );
/* Clean up memory */
XLALDestroyMultiNoiseWeights ( multiWeightsCorrect );
XLALDestroyMultiNoiseWeights ( multiWeightsXLAL );
XLALDestroyMultiPSDVector ( multiPSDs );
XLALDestroyMultiSFTVector ( multiSFTs );
XLALDestroySFTCatalog ( catalog );
/* check for memory-leaks */
LALCheckMemoryLeaks();
return XLAL_SUCCESS;
} /* main() */
示例11: Freemem
int Freemem(void)
{
LALFree(po);
LALFree(p);
LALCheckMemoryLeaks();
return 0;
}
示例12: main
int main( void )
{
/* Create hash table */
LALBitset *bs = XLALBitsetCreate();
XLAL_CHECK_MAIN( bs != NULL, XLAL_EFUNC );
/* Create some random bits */
BOOLEAN XLAL_INIT_DECL( bits, [4096] );
gsl_rng *r = gsl_rng_alloc( gsl_rng_mt19937 );
XLAL_CHECK_MAIN( r != NULL, XLAL_ESYS );
int nbits = 0;
for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) {
bits[n] = ( gsl_rng_uniform( r ) > 0.44 );
nbits += bits[n] ? 1 : 0;
}
/* Create random index offset into bitset */
const UINT8 n0 = gsl_rng_get( r ) % 65536;
/* Print information */
printf("nbits = %i, n0 = %"LAL_UINT8_FORMAT"\n", nbits, n0);
/* Set bits */
for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) {
XLAL_CHECK_MAIN( XLALBitsetSet( bs, n0 + n, bits[n] ) == XLAL_SUCCESS, XLAL_EFUNC );
}
/* Get bits */
for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) {
BOOLEAN is_set = 0;
XLAL_CHECK_MAIN( XLALBitsetGet( bs, n0 + n, &is_set ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK_MAIN( !is_set == !bits[n], XLAL_EFAILED, "Inconsistent bit at index %"LAL_UINT8_FORMAT": LALBitset=%i, reference=%i", n0 + n, is_set, bits[n] );
}
/* Clear bitset */
XLAL_CHECK_MAIN( XLALBitsetClear( bs ) == XLAL_SUCCESS, XLAL_EFUNC );
for ( size_t n = 0; n < XLAL_NUM_ELEM( bits ); ++n ) {
BOOLEAN is_set = 0;
XLAL_CHECK_MAIN( XLALBitsetGet( bs, n0 + n, &is_set ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK_MAIN( !is_set, XLAL_EFAILED, "Bit still set at index %"LAL_UINT8_FORMAT, n0 + n );
}
/* Cleanup */
gsl_rng_free( r );
XLALBitsetDestroy( bs );
/* Check for memory leaks */
LALCheckMemoryLeaks();
return EXIT_SUCCESS;
}
示例13: main
// ==================== function definitions ====================
int main(void)
{
// ---------- test angle conversions ----------
XLAL_CHECK_MAIN ( test_HMS_RAD() == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK_MAIN ( test_DMS_RAD() == XLAL_SUCCESS, XLAL_EFUNC );
// check for memory leaks
LALCheckMemoryLeaks();
return EXIT_SUCCESS;
} // main()
示例14: main
/**
* MAIN function
*/
int main(void)
{
XLAL_CHECK ( test_XLALSFTVectorToLFT() == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( test_XLALSincInterpolateCOMPLEX8TimeSeries() == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( test_XLALSincInterpolateSFT() == XLAL_SUCCESS, XLAL_EFUNC );
LALCheckMemoryLeaks();
return XLAL_SUCCESS;
} /* main() */
示例15: main
int main(int argc, char *argv[])
{
const double H0 = 0.72 * LAL_H0FAC_SI; // Hubble's constant in seconds
const double srate = 16384.0; // sampling rate in Hertz
const size_t length = 65536; // number of points in a segment
const size_t stride = length / 2; // number of points in a stride
size_t i, n;
REAL8FrequencySeries *OmegaGW = NULL;
REAL8TimeSeries **seg = NULL;
LIGOTimeGPS epoch;
gsl_rng *rng;
XLALSetErrorHandler(XLALAbortErrorHandler);
parseargs(argc, argv);
XLALGPSSetREAL8(&epoch, tstart);
gsl_rng_env_setup();
rng = gsl_rng_alloc(gsl_rng_default);
OmegaGW = XLALSimSGWBOmegaGWFlatSpectrum(Omega0, flow, srate/length, length/2 + 1);
n = duration * srate;
seg = LALCalloc(numDetectors, sizeof(*seg));
for (i = 0; i < numDetectors; ++i)
seg[i] = XLALCreateREAL8TimeSeries("STRAIN", &epoch, 0.0, 1.0/srate, &lalStrainUnit, length);
XLALSimSGWB(seg, detectors, numDetectors, 0, OmegaGW, H0, rng); // first time to initilize
while (1) { // infinite loop
double t0 = XLALGPSGetREAL8(&seg[0]->epoch);
size_t j;
for (j = 0; j < stride; ++j, --n) { // output first stride points
if (n == 0) // check if we're done
goto end;
printf("%.9f", t0 + j * seg[0]->deltaT);
for (i = 0; i < numDetectors; ++i)
printf("\t%e", seg[i]->data->data[j]);
printf("\n");
}
XLALSimSGWB(seg, detectors, numDetectors, stride, OmegaGW, H0, rng); // make more data
}
end:
for (i = 0; i < numDetectors; ++i)
XLALDestroyREAL8TimeSeries(seg[i]);
XLALFree(seg);
XLALDestroyREAL8FrequencySeries(OmegaGW);
LALCheckMemoryLeaks();
return 0;
}