int main(int argc, char const *argv[]) { int f; std::chrono::high_resolution_clock::duration total; const TestClass& test = TestClass(); const VirtualBase& testVirtual = VirtualChild(); auto start = std::chrono::high_resolution_clock::now(); for(int i = 0; i < 2000000000; ++i) { #ifdef IF_VIRTUAL f = testVirtual.virtualMethod(); #endif #ifdef IF_INLINE if(f == 5) f = 1; else f = 5; #endif #ifdef IF_INLINE_PRED if(f == 1) f = 1; else f = 5; #endif #ifdef IF_FUNCTION if(f == 5) f = freeFunction2(); else f = freeFunction(); #endif #ifdef IF_FUNCTION_PRED if(f == 1) f = freeFunction2(); else f = freeFunction(); #endif #ifdef CALL_VIRTUAL testVirtual.virtualMethod(); #endif #ifdef CALL_METHOD test.method(); #endif #ifdef CALL_FUNCTION freeFunction(); #endif } auto end = std::chrono::high_resolution_clock::now(); total = (end - start); auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(total); std::cout << dur.count() << std::endl; return 0; }
void freeProgFunctions(ProgInfo* prgFuncs){ int i; for (i=0; i<prgFuncs->n; i++){ freeFunction(prgFuncs->functions[i]); } free(prgFuncs->functions); free(prgFuncs); }
/////////////////////////////////////////////////////////////////////// // Class : CDelayedObject // Method : ~CDelayedObject // Description : /// \brief Dtor // Return Value : - // Comments : CDelayedObject::~CDelayedObject() { atomicDecrement(&stats.numDelayeds); dataRefCount[0]--; if (dataRefCount[0] == 0) { if (freeFunction != NULL) freeFunction(data); delete dataRefCount; } }
/** * Deallocate memory. * * @param[in] portLibrary The port library * @param[in] memoryPointer Base address of memory to be deallocated. * * @note memoryPointer may be NULL. In that case, no action is taken. */ void omrmem_free_memory(struct OMRPortLibrary *portLibrary, void *memoryPointer) { free_memory_func_t freeFunction = omrmem_free_memory_basic; Trc_PRT_mem_omrmem_free_memory_Entry(memoryPointer); if (memoryPointer != NULL) { memoryPointer = unwrapBlockAndCheckTags(portLibrary, memoryPointer); freeFunction(portLibrary, memoryPointer); } Trc_PRT_mem_omrmem_free_memory_Exit(); }
int main() { int X = 0; bool B = false; assert(X == 1); assert(X = 1); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect [misc-assert-side-effect] my_assert(X = 1); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found my_assert() with side effect convoluted_assert(X = 1); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found convoluted_assert() with side effect not_my_assert(X = 1); assert(++X); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert(!B); assert(B || true); assert(freeFunction()); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect MyClass mc; assert(mc.badFunc(0, 1)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert(mc.goodFunc(0, 1)); MyClass mc2; assert(mc2 = mc); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert(-mc > 0); MyClass *mcp; assert(mcp = new MyClass); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert((delete mcp, false)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert((throw 1, false)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() with side effect assert2(1 == 2 - 1); return 0; }
extern void DSStackFreeWithFunction(DSStack *stack, void * function) { void (*freeFunction)(void *) = function; if (stack == NULL) { DSError(M_DS_NULL ": Design Space Stack is NULL", A_DS_ERROR); goto bail; } while (stack->count > 0) { if (freeFunction == NULL) DSStackPop(stack); else freeFunction(DSStackPop(stack)); } pthread_mutex_destroy(&stack->pushpop); DSSecureFree(stack); bail: return; }