int main() { int i = 0; elem *arrayOne; elem *arrayTwo; arraySize = __VERIFIER_nondet_int(); assume(arraySize > 0); arrayOne = (elem*)malloc(arraySize * sizeof(elem)); arrayTwo = (elem*)malloc(arraySize * sizeof(elem)); resetArray(arrayOne); setArray(arrayTwo); initializeCount(arrayTwo); for (i = 0; i < arraySize; i++) { assert(arrayOne[i].status == RESET); assert(arrayTwo[i].status == SET); assert(arrayTwo[i].count == 0); } initializeCount(arrayOne); setArray(arrayOne); resetArray(arrayTwo); for (i = arraySize - 1; i >= 0; i--) { assert(arrayOne[i].count != 0 || arrayOne[i].status != SET || arrayTwo[i].status != RESET); } free(arrayOne); free(arrayTwo); return 0; }
int main() { int i = 0; int *arrayOne = (int*)malloc(MAXSIZE * sizeof(int)); int *arrayTwo = (int*)malloc(MAXSIZE * sizeof(int)); resetArray(arrayOne); setArray(arrayTwo); for (i = 0; i < MAXSIZE; i++) { __SMACK_assert(arrayOne[i] == RESET); __SMACK_assert(arrayTwo[i] == SET); } setArray(arrayOne); resetArray(arrayTwo); for (i = 0; i < MAXSIZE; i++) { __SMACK_assert(arrayOne[i] == SET); __SMACK_assert(arrayTwo[i] == RESET); } free(arrayOne); free(arrayTwo); return 0; }
int main() { int i = 0; elem *arrayOne = (elem*)malloc(arraySize * sizeof(elem)); elem *arrayTwo = (elem*)malloc(arraySize * sizeof(elem)); resetArray(arrayOne); setArray(arrayTwo); initializeCount(arrayTwo); for (i = 0; i < arraySize; i++) { __SMACK_assert(arrayOne[i].status == RESET); __SMACK_assert(arrayTwo[i].status == SET); __SMACK_assert(arrayTwo[i].count == 0); } initializeCount(arrayOne); setArray(arrayOne); resetArray(arrayTwo); for (i = 0; i < arraySize; i++) { __SMACK_assert(arrayOne[i].count == 0); __SMACK_assert(arrayOne[i].status == SET); __SMACK_assert(arrayTwo[i].status == RESET); } free(arrayOne); free(arrayTwo); return 0; }
void Foam::cfdemCloud::setForces() { resetArray(fluidVel_,numberOfParticles(),3); resetArray(impForces_,numberOfParticles(),3); resetArray(expForces_,numberOfParticles(),3); resetArray(DEMForces_,numberOfParticles(),3); resetArray(Cds_,numberOfParticles(),1); for (int i=0;i<cfdemCloud::nrForceModels();i++) cfdemCloud::forceM(i).setForce(); }
void Foam::cfdemCloud::setForces() { resetArray(fluidVel_,numberOfParticles(),3); resetArray(impForces_,numberOfParticles(),3); resetArray(expForces_,numberOfParticles(),3); resetArray(DEMForces_,numberOfParticles(),3); resetArray(Cds_,numberOfParticles(),1); //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= //reset all USER-defined particle fields zeroizeParticleDatFieldsUserCFDEMToExt(); //=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*= for (int i=0;i<cfdemCloud::nrForceModels();i++) cfdemCloud::forceM(i).setForce(); }
bool DocumentSourceUnwind::advance() { DocumentSource::advance(); // check for interrupts if (pUnwinder.get() && pUnwinder->more()) { pUnwindValue = pUnwinder->next(); return true; } /* release the last document and advance */ resetArray(); return pSource->advance(); }
void outOfPlaceSort(void (*funct)(int *a, int n, int *endResult), int which){ printf("Performing %s with MIN = %d, MAX = %d and STEP = %d\n\n",outOfPlaceSortingFunctionNames[which],MIN,MAX,STEP); FILE *fpBest,*fpWorst,*fpAverage; int currentCount; //! Insertion Sort fpBest = fopen(formFileName(outOfPlaceSortingFunctionNames[which],"Best"),"w"); fpAverage = fopen(formFileName(outOfPlaceSortingFunctionNames[which],"Average"),"w"); fpWorst = fopen(formFileName(outOfPlaceSortingFunctionNames[which],"Worst"),"w"); for(currentCount=MIN; currentCount<=MAX; currentCount+=STEP) { int *a, *b=NULL; resetArray(&b,currentCount); generateBest(&a,currentCount); (*funct)(a, currentCount,b); fprintf(fpBest,"%d,%lu,%lu,%lu\n",currentCount,assignments,comparisons,assignments+comparisons); resetCounters(); resetArray(&b,currentCount); generateAverage(&a,currentCount); (*funct)(a, currentCount,b); fprintf(fpAverage,"%d,%lu,%lu,%lu\n",currentCount,assignments,comparisons,assignments+comparisons); resetCounters(); resetArray(&b,currentCount); generateWorst(&a,currentCount); (*funct)(a, currentCount,b); fprintf(fpWorst,"%d,%lu,%lu,%lu\n",currentCount,assignments,comparisons,assignments+comparisons); resetCounters(); printf("N: %d\n",currentCount); } fclose(fpBest); fclose(fpAverage); fclose(fpWorst); printf("Finished %s with MIN = %d, MAX = %d and STEP = %d\n\n",outOfPlaceSortingFunctionNames[which],MIN,MAX,STEP); }
void Texture :: allocate(unsigned align) { deallocate(); resetArray(align); mArray.dataCalloc(); mPixelsUpdated = true; }
JsonData& operator = ( std::initializer_list< JsonData > rhs ) { resetArray( rhs ); return *this; }
intrusive_ptr<Document> DocumentSourceUnwind::getCurrent() { if (!pNoUnwindDocument.get()) { intrusive_ptr<Document> pInDocument(pSource->getCurrent()); /* create the result document */ pNoUnwindDocument = pInDocument; fieldIndex.clear(); /* First we'll look to see if the path is there. If it isn't, we'll pass this document through. If it is, we record the indexes of the fields down the field path so that we can quickly replace them as we clone the documents along the field path. We have to clone all the documents along the field path so that we don't share the end value across documents that have come out of this pipeline operator. */ intrusive_ptr<Document> pCurrent(pInDocument); const size_t pathLength = unwindPath.getPathLength(); for(size_t i = 0; i < pathLength; ++i) { size_t idx = pCurrent->getFieldIndex( unwindPath.getFieldName(i)); if (idx == pCurrent->getFieldCount() ) { /* this document doesn't contain the target field */ resetArray(); return pInDocument; break; } fieldIndex.push_back(idx); Document::FieldPair fp(pCurrent->getField(idx)); intrusive_ptr<const Value> pPathValue(fp.second); if (i < pathLength - 1) { if (pPathValue->getType() != Object) { /* can't walk down the field path */ resetArray(); uassert(15977, str::stream() << unwindName << ": cannot traverse field path past scalar value for \"" << fp.first << "\"", false); break; } /* move down the object tree */ pCurrent = pPathValue->getDocument(); } else /* (i == pathLength - 1) */ { if (pPathValue->getType() != Array) { /* last item on path must be an array to unwind */ resetArray(); uassert(15978, str::stream() << unwindName << ": value at end of field path must be an array", false); break; } /* keep track of the array we're unwinding */ pUnwindArray = pPathValue; if (pUnwindArray->getArrayLength() == 0) { /* The $unwind of an empty array is a NULL value. If we encounter this, use the non-unwind path, but replace pOutField with a null. Make sure unwind value is clear so the array is removed. */ pUnwindValue.reset(); intrusive_ptr<Document> pClone(clonePath()); resetArray(); return pClone; } /* get the iterator we'll use to unwind the array */ pUnwinder = pUnwindArray->getArray(); assert(pUnwinder->more()); // we just checked above... pUnwindValue = pUnwinder->next(); } } } /* If we're unwinding a field, create an alternate document. In the alternate (clone), replace the unwound array field with the element at the appropriate index. */ if (pUnwindArray.get()) { /* clone the document with an array we're unwinding */ intrusive_ptr<Document> pUnwindDocument(clonePath()); return pUnwindDocument; } return pNoUnwindDocument; }