void ProperlySeededRandomGeneratorCheck::check( const MatchFinder::MatchResult &Result) { const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructExpr>("ctor"); if (Ctor) checkSeed(Result, Ctor); const auto *Func = Result.Nodes.getNodeAs<CXXMemberCallExpr>("seed"); if (Func) checkSeed(Result, Func); const auto *Srand = Result.Nodes.getNodeAs<CallExpr>("srand"); if (Srand) checkSeed(Result, Srand); }
void NOX::Random::setSeed(int s) { int ss = checkSeed("setSeed", s); std::srand(ss); seed = static_cast<double>(s); }
int main(int argc, char *argv[]) { int seedX=-1,seedY=-1; char szWrap[MAXNAME], szUnwrap[MAXNAME]; meta_parameters *meta; logflag=0; while (currArg < (argc-2)) { char *key = argv[currArg++]; if (strmatch(key,"-log")) { CHECK_ARG(1); strcpy(logFile,GET_ARG(1)); fLog = FOPEN(logFile, "a"); logflag = 1; } else if (strmatch(key,"-x")) { CHECK_ARG(1); sscanf(GET_ARG(1), "%d", &seedX); } else if (strmatch(key,"-y")) { CHECK_ARG(1); sscanf(GET_ARG(1), "%d", &seedY); } else { printf("\n ***Invalid option: %s\n", argv[currArg-1]); usage(argv[0]); } } create_name(szWrap, argv[currArg++], ".img"); create_name(szUnwrap, argv[currArg], ".img"); printf("%s\n",date_time_stamp()); printf("Program: escher\n\n"); if (logflag) { StartWatchLog(fLog); printLog("Program: escher\n\n"); } meta = meta_read(szWrap); wid = meta->general->sample_count; len = meta->general->line_count; if ((seedX==-1)&&(seedY==-1)) { seedX=wid/2; seedY=len/2; } meta_write(meta, szUnwrap); size = wid*len; mask = (Uchar *)calloc(size, sizeof(Uchar)); im = (Uchar *)calloc(size, sizeof(Uchar)); phase = (float *)MALLOC(sizeof(float)*size); /*coh = (float *)MALLOC(sizeof(float)*size);*/ /* perform steps*/ printf("\n begin unwrapping phase...\n"); loadWrappedPhase(szWrap); groundBorder(); makeMask(); doStats(" after makeMask():"); installCordon("cordon"); cutMask(); doStats(" after cutMask():"); #if DO_DEBUG_CHECKS saveMask((char *)mask, "test"); verifyCuts(); #endif checkSeed(&seedX, &seedY); integratePhase(seedX, seedY); doStats(" after integratePhase():"); finishUwp(); saveMask(mask, szUnwrap); saveUwp(szUnwrap); /* clean up & save*/ free(mask); free(im); free(phase); return(0); }