int* foo(){ int** x = SAFEMALLOC(10); int** y = SAFEMALLOC(10); bar1(x); free(*x); free(x); bar1(y); free(y); printf("%d",x,y); }
int foo2 (void) { union un u; u.i = 1; return foo1 (u) + bar1 (u); }
void VUMeter::drawBar(QPainter *painter) { painter->save(); QLinearGradient linGrad(50, 0, 50, 500); linGrad.setColorAt(0, colorHigh); linGrad.setColorAt(1, colorLow); linGrad.setSpread(QGradient::PadSpread); painter->setBrush(linGrad); //绘制柱状条 QRectF bar3(20, 50, 25, 450); painter->drawRect(bar3); QRectF bar4(55, 50, 25, 450); painter->drawRect(bar4); //绘制柱状背景 painter->setBrush(QColor(40, 40, 40)); double length = 450.0; double leftBar = abs(length * (minValue - leftValue) / (maxValue - minValue)); double rightBar = abs(length * (minValue - rightValue) / (maxValue - minValue)); QRectF bar1(20, 50, 25, 450 - leftBar); painter->drawRect(bar1); QRectF bar2(55, 50, 25, 450 - rightBar); painter->drawRect(bar2); painter->setPen(QPen(Qt::black, 2)); for (int i = 0; i <= 60; i++) { painter->drawLine(21, 500 - 450 * i / 60, 44, 500 - 450 * i / 60); painter->drawLine(56, 500 - 450 * i / 60, 79, 500 - 450 * i / 60); } painter->restore(); }
void finish_struct (tree t, tree fieldlist, tree attributes) { union tree_node * x; if (pedantic) { x = fieldlist; if (x->decl.name == 0) { while (x) x = x->common.chain; foo (fieldlist); } } x = fieldlist; if (x) { do { x = x->common.chain; } while (x != 0); } bar1 (&fieldlist); }
int bar7(Bar *pBar) { if (IsDebuggerPresent()) { return 30; } return bar0(pBar) + bar1(pBar) + 2; }
int main() { Foo foo; fprintf(stderr, "Foo::add(2,4) = %d\n" ,bar1(2,4, &foo, &Foo::add)); fprintf(stderr, "Foo::mult(3,5) = %d\n", bar2(3,5, &foo, &Foo::mult)); fprintf(stderr, "Foo::negate(6) = %d\n" , bar3(6, &Foo::negate)); return 0; }
void foo (unsigned int a, unsigned int b) { if (a >= b) bar1 (); else if (a <= b) bar2 (); }
void foo1 (long a, long b) { long array[128]; long *c = array; for (b=0; b < a; b++) c[b] = bar1 (c[b]); dummy1 (c); }
int foo (void) { int len; if (bar1 (&len)) { char devpath [len]; if (bar2 (devpath) == len) return len; } return -1; }
int main() { VECTOR::Vector foo(3.0, 4.0); std::cout << foo << std::endl; VECTOR::Vector bar(3.0, 4.0, VECTOR::Vector::Mode(0)); std::cout << bar << std::endl; VECTOR::Vector foo1(3.0, 4.0, VECTOR::Vector::Mode(1)); std::cout << foo1 << std::endl; VECTOR::Vector bar1(3.0, 4.0, VECTOR::Vector::POL); std::cout << bar1 << std::endl; return 0; }
void bar2 (int n, rvec x[]) { int m; matrix trans; foo (trans); if (det (trans) < 0) { for(m=0; (m<DIM); m++) trans[ZZ][m] = -trans[ZZ][m]; } bar1 (n,(int*) 0,x,trans); }
int main(int argc, char **argv) { void *ptr = (void *)&foo7; g(foo8); (void)ptr; a::foo(ptr); // expected-error {{interrupt service routine cannot be called directly}} bar1(foo); #ifndef __x86_64__ // expected-error@+2 {{interrupt service routine cannot be called directly}} #endif foo7((int *)argv, argc); foo8((int *)argv); // expected-error {{interrupt service routine cannot be called directly}} bar(argv); // expected-note {{in instantiation of function template specialization 'bar<char *>' requested here}} return 0; }
void foo1 (int a, struct T b) { struct S x; struct S *c = &x; float z, *k = &z; if (a) c = &b.s; b.s.w = 3; /* This call should NOT be marked as clobbering 'x' and 'b'. */ x = bar1 (*c, *c); if (b.s.w != 3) link_error (); }
JSBool facButton(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { diaElemButton bar1("Button",clickMe,NULL); diaElem *elems[]={&bar1 }; if(diaFactoryRun("Test Button",1,elems)) { *rval = BOOLEAN_TO_JSVAL(1); }else *rval = BOOLEAN_TO_JSVAL(0); return JS_TRUE; }
JSBool facBar(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { diaElemBar bar1(25,"25"); diaElemBar bar2(65,"65"); diaElem *elems[]={&bar1,&bar2 }; if(diaFactoryRun("Test FileRead",2,elems)) { *rval = BOOLEAN_TO_JSVAL(1); }else *rval = BOOLEAN_TO_JSVAL(0); return JS_TRUE; }
int main (void) { // non-lazy reference to foo2 p = &foo2; // lazy reference to foo4 foo4(); // non-lazy reference to bar2 p = &bar2; // lazy reference to bar4 and bar1 bar4(); bar1(); return 0; }
void foo (int a) { if (a < 100) return; if (200 < a) return; switch (a) { case 99: bar0 (); return; case 100: bar1 (); return; case 101: bar2 (); return; case 102: bar3 (); return; } }
void QProg::paintBar() { QPainter painter(this); painter.setWindow(0, 0, 470, 80); painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(QColor(70, 70, 70)); //background color QRectF back(20, 10, 360, 60); painter.drawRoundRect(back, 3); // chech value if (actVal > maxVal) { return; } if (actVal < minVal) { return; } // waiting state if min = max if(minVal == maxVal) { painter.setBrush(colBar); QRectF bar(40, 10, 40, 60); QRectF bar1(130, 10, 40, 60); QRectF bar2(220, 10, 40, 60); QRectF bar3(310, 10, 40, 60); painter.drawRoundRect(bar, 3); painter.drawRoundRect(bar1, 3); painter.drawRoundRect(bar2, 3); painter.drawRoundRect(bar3, 3); return; } // check positive or negative scale if (maxVal >= 0 && minVal >= 0 || maxVal >= 0 && minVal <= 0) { lengthBar = 360-360 * (maxVal-actVal)/(maxVal-minVal); } if (maxVal <= 0 && minVal <= 0) { lengthBar = 360 * (minVal-actVal)/(minVal-maxVal); } // length and color bar painter.setBrush(colBar); QRectF bar(20, 10, lengthBar, 60); painter.drawRoundRect(bar, 3); emit valueChanged(actVal); }
void BelowsEnh::paintBar() { QPainter painter(this); painter.setWindow(0, 0, 100, 540); painter.setRenderHint(QPainter::Antialiasing); QLinearGradient linGrad(50, 0, 50, 500); linGrad.setColorAt(0, colHigh); linGrad.setColorAt(1, colLow); linGrad.setSpread(QGradient::PadSpread); painter.setBrush(linGrad); // draw color bar // QRectF bar3(20, 50, 25, 450); QRectF bar3(20, 50, 60, 450); painter.drawRect(bar3); //QRectF bar4(55, 50, 25, 450); //painter.drawRect(bar4); // draw background bar painter.setBrush(QColor(40, 40, 40)); double length = 450.0; double leftBar = abs(length * (min-leftVal)/(max-min)); double rightBar = abs(length * (min-rightVal)/(max-min)); QRectF bar1(20, 50, 60, 450-leftBar); painter.drawRect(bar1); //QRectF bar2(55, 50, 25, 450-rightBar); //painter.drawRect(bar2); painter.setPen(QPen(Qt::black, 2)); for (int i = 0; i <=60; i++) { //painter.drawLine(21, 500-450*i/60, 44, 500-450*i/60); painter.drawLine(21, 500-450*i/60, 79, 500-450*i/60); //painter.drawLine(56, 500-450*i/60, 79, 500-450*i/60); } }
int foo(void) { int a,b,g; int i,len; int stop; len = 10; stop = 0; for (i=0; i<len; i++) { a = bar1() ? 0 : 1; b = bar2() ? 0 : 1; g = bar3() ? 0 : 1; if (stop = ((a+b) % 2 != g)) break; } return stop; }
int foo1 (e_u8 a[4][N], int b1, int b2, e_u8 b[M+1][4][N]) { btype n; int r, m; switch (b2) { case 128: n = 4; break; case 192: n = 6; break; case 256: n = 8; break; default : return (-2); } switch (MAX(b1,b2)) { case 128: m = 10; break; case 192: m = 12; break; case 256: m = 14; break; default : return (-3); } bar1(a,b[m],n); bar2(a,x,n); return 0; }
int main ( int argc, char** argv ){ if ( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } // make sure SDL cleans up before exit atexit(SDL_Quit); // create a new window screen = SDL_SetVideoMode(900, 600, 8, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 640x480 video: %s\n", SDL_GetError()); return 1; } Fleet f; Bullet b3; f.asignBullet(&b3); Barrier bar1(000,98,1); /* Barrier bar2(000,200,1); Barrier bar3(000,300,1); Barrier bar4(000,400,0); Barrier bar5(000,500,0); Barrier bar6(000,599,0);*/ Ship s2; s2.position( (GAME_W /2) + 100 ,GAME_H-30); //s2.setMode(2); Bullet b2; b2.setDownOrientation(); s2.asignBullet(&b2); Ship s1; //s1.setMode(1); s1.position( (GAME_W / 2)- 100 , GAME_H-30); Bullet b1; s1.asignBullet(&b1); SideBar sb; actors.push_back(&b1); actors.push_back(&b2); // actors.push_back(&b3); // actors.push_back(&f); actors.push_back(&bar1); Bonus bonus; actors.push_back(&bonus); actors.push_back(&sb); Stairs stairs(160,98,1); actors.push_back(&stairs); actors.push_back(&s1); actors.push_back(&s2); Uint8 * keystate; bool done = false; while (!done) { //Start the frame timer fps.start(); keystate = SDL_GetKeyState(NULL); if(keystate[SDLK_LEFT]) { //if(!s1.climbing){ s1.moveLeft(); //} } if(keystate[SDLK_RIGHT]) { s1.moveRight(); } if(keystate[SDLK_UP]) { int collided = 0; if(s1.onGround){ for (int i=0; i<Stairs::SHIPS_QTY; i++) { if (check_collision(s1.rect,stairs.rect[i])) { s1.climbing = true; s1.moveUp(); collided = 1; //std::cout << "Climbing en true??" << s1.climbing << "\n"; } } if(!collided){ std::cout << "ELSEClimbing en true??" << s1.climbing << "\n"; s1.climbing= false; s1.onGround = false; /*std::cout << "stairs width " << stairs.rect[1].w << "\n"; std::cout << "stairs height " << stairs.rect[1].h << "\n";*/ } } } if(keystate[SDLK_DOWN]) { for (int i=0; i<Stairs::SHIPS_QTY; i++) { if (check_collision(s1.rect,stairs.rect[i])) { SDL_Rect * r; r = bar1.getNextBaseFloor(stairs.rect[i].y+stairs.rect[i].h); std::cout << "Recta a chequear <<<<<<< " << r->y << " \n"; if(s1.rect.y+s1.rect.h >= r->y){ std::cout << "Entra al if " << " \n"; s1.onGround = false; s1.climbing = false; } else{ s1.climbing = true; //S1.climbingDown = true; s1.moveDown(); } //std::cout << "Climbing en true??" << s1.climbing << "\n"; }else{ //std::cout << "Entra al else Climbing en true??" << s1.climbing << "\n"; //s1.climbing= false; //s1.onGround = false; } } } if(keystate[SDLK_a]) { s2.moveLeft(); } if(keystate[SDLK_d]) { s2.moveRight(); } SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: // exit if ESCAPE is pressed if (event.key.keysym.sym == SDLK_ESCAPE) { done = true; } if (event.key.keysym.sym == SDLK_w) { s2.jump(); } if (event.key.keysym.sym == SDLK_SPACE) { s1.jump(); } break; } // end switch } // clear screen SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); for(std::vector<IActor*>::iterator it = actors.begin(); it != actors.end(); ++it) { (*it)->blit(); } if(!s1.climbing && !s1.onGround){ for (int i=0; i<Barrier::SHIPS_QTY; i++) { if (check_collision(s1.rect,bar1.rect[i])) { //s1.climbing = true; //S1.climbingDown = true; //std::cout << "Climbing en true??" << s1.climbing << "\n"; //s1.moveDown(); /* std::cout << "entra en collision con bar" << i << " \n"; std::cout << "climb" << s1.climbing << "\n"; std::cout << "onGround" << s1.onGround << "\n"; std::cout << "end col" << "\n";*/ s1.rect.y = bar1.rect[i].y-28; s1.speedY = 0.0; s1.onGround = true; } } } if(s1.climbing){ int collided = 0; for (int i=0; i<Stairs::SHIPS_QTY; i++) { if (check_collision(s1.rect,stairs.rect[i])) { //s1.climbing = true; //s1.moveUp(); collided = 1; //std::cout << "Climbing en true??" << s1.climbing << "\n"; } } if(!collided){ //std::cout << "ELSEClimbing en true??" << s1.climbing << "\n"; s1.climbing= false; s1.onGround = false; //std::cout << "stairs width " << stairs.rect[1].w << "\n"; //std::cout << "stairs height " << stairs.rect[1].h << "\n"; } } for (int i=0; i<Stairs::SHIPS_QTY; i++) { if (check_collision(bonus.rect,stairs.rect[i])) { SDL_Rect * r; r = bar1.getNextBaseFloor(stairs.rect[i].y+stairs.rect[i].h); //std::cout << "Recta a chequear <<<<<<< " << r->y << " \n"; if(bonus.rect.y+bonus.rect.h > r->y){ //std::cout << "Entra al if " << " \n"; //s1.onGround = false; bonus.climbing = false; } else{ bonus.climbing = true; //S1.climbingDown = true; //s1.moveDown(); } //std::cout << "Climbing en true??" << s1.climbing << "\n"; }else{ //std::cout << "Entra al else Climbing en true??" << s1.climbing << "\n"; //s1.climbing= false; //s1.onGround = false; } } SDL_Flip(screen); //Cap the frame rate if (fps.get_ticks() < 1000 / FRAMES_PER_SECOND) { SDL_Delay( (1000 / FRAMES_PER_SECOND) - fps.get_ticks() ); } }//end game loop for(std::vector<IActor*>::iterator it = actors.begin(); it != actors.end(); ++it) { (*it)->free(); } printf("Exited cleanly\n"); return 0; }
void ExclusivePoolMgr::LoadFromDB() { QueryResult* result = WorldDatabase.Query("SELECT * FROM exclusive_pool"); if (!result) { sLog.outString(">> Table exclusive_pool is empty."); sLog.outString(); return; } BarGoLink bar(result->GetRowCount()); do { Field* fields = result->Fetch(); bar.step(); uint32 poolID = fields[0].GetUInt32(); time_t respawnTime = fields[1].GetUInt64(); m_pools[poolID] = ExclusivePool(poolID, respawnTime); } while (result->NextRow()); delete result; sLog.outBasic("Loaded %lu exclusive events...", m_pools.size()); QueryResult* result1 = WorldDatabase.Query("SELECT * FROM exclusive_pool_creature"); if (!result1) { sLog.outString(">> Table exclusive_pool_creature is empty."); sLog.outString(); } else { BarGoLink bar1(result1->GetRowCount()); uint32 counter = 0; do { Field* fields = result1->Fetch(); ++counter; bar1.step(); uint32 guid = fields[0].GetUInt32(); uint32 poolID = fields[1].GetUInt32(); uint32 groupID = fields[2].GetUInt32(); const CreatureData* pData = sObjectMgr.GetCreatureData(guid); if (pData) m_pools[poolID].m_objects[groupID].push_back(pData->GetObjectGuid(guid)); } while (result1->NextRow()); delete result1; sLog.outBasic("Loaded %u exclusive_pool_creatures...", counter); } QueryResult* result2 = WorldDatabase.Query("SELECT * FROM exclusive_pool_spot"); if (!result2) { sLog.outString(">> Table exclusive_pool_spot is empty."); sLog.outString(); } else { BarGoLink bar2(result2->GetRowCount()); uint32 counter = 0; do { Field* fields = result2->Fetch(); ++counter; bar2.step(); uint32 poolID = fields[1].GetUInt32(); uint32 mapID = fields[2].GetUInt32(); float x = fields[3].GetFloat(); float y = fields[4].GetFloat(); float z = fields[5].GetFloat(); float o = fields[6].GetFloat(); ExclusivePoolSpot spot = { mapID, x, y, z, o }; m_poolSpots[poolID].push_back(spot); } while (result2->NextRow()); delete result2; sLog.outBasic("Loaded %u exclusive_pool_spots...", counter); } QueryResult* result3 = WorldDatabase.Query("SELECT * FROM exclusive_pool_respawn"); if (!result3) { sLog.outString(">> Table exclusive_pool_spot is empty."); sLog.outString(); } else { BarGoLink bar3(result3->GetRowCount()); do { Field* fields = result3->Fetch(); bar3.step(); uint32 poolID = fields[0].GetUInt32(); time_t currentRespawnTime = fields[1].GetUInt64(); m_pools[poolID].currentRespawnTime = currentRespawnTime; } while (result3->NextRow()); delete result3; } }
int bar2(Bar *pBar) { return bar0(pBar) + bar1(pBar) + 2; }
int foo1 (union un u) { bar1 (u); return u.i; }
void *Thread1(void *x) { usleep(1000000); bar1(); return NULL; }
void *Thread1(void *x) { sleep(1); bar1(); return NULL; }
int main() { bar1(); bar2(); return 0; }
int main() { return bar1(); }
void *Thread1(void *x) { barrier_wait(&barrier); bar1(); return NULL; }