static int display_philo_bar(SDL_Surface *screen, t_data *data, int bar_size, Uint32 color) { SDL_Rect pos; t_size size; float size_rest; float size_eat; float size_think; float total; pos.y = WIN_HEIGHT - bar_size - 11 + 3; pos.x = 100 + BAR_WIDTH * (data->id + 1) + 1; if (!(total = data->eaten_plates + data->hours_slept + data->hours_thought)) total = 0.1; size_rest = bar_size / (total / data->hours_slept); size_think = bar_size / (total / data->hours_thought); size_eat = bar_size / (total / data->eaten_plates); if (!display_rect(screen, init_size(&size, size_rest, BAR_WIDTH - 2), &pos, color & 0x555555)) return (0); pos.y = WIN_HEIGHT - bar_size - 11 + size_rest + 2; if (!display_rect(screen, init_size(&size, size_think, BAR_WIDTH - 2), &pos, color & 0xaaaaaa)) return (0); pos.y = WIN_HEIGHT - bar_size - 11 + size_rest + size_think + 1; return (!display_rect(screen, init_size(&size, size_eat, BAR_WIDTH - 2), &pos, color)); }
void init_term(t_area *ar, char **argv, int argc) { extern char **environ; ar->term = cpy_from_env(environ, "TERM="); if (ar->term == NULL) { my_put_error(ERR_TERM); exit(EXIT_FAILURE); } x_tgetent(tgetent(ar->bp, ar->term)); ar->area = ar->t; ar->clstr = xtgetstr("cl", &(ar->area)); ar->cmstr = xtgetstr("cm", &(ar->area)); ar->sostr = xtgetstr("so", &(ar->area)); ar->sestr = xtgetstr("se", &(ar->area)); ar->usstr = xtgetstr("us", &(ar->area)); ar->uestr = xtgetstr("ue", &(ar->area)); ar->li = tgetnum("li"); ar->co = tgetnum("co"); tputs(ar->clstr, 1, my_outc); argc = make_argc(ar, argc); ar->ac = argc - 1; ar->res = malloc(argc * sizeof(*(ar->res))); x_malloc(ar->res, argc); init_size(ar, argv); my_arg_cpy(ar, argv, argc); }
int zmq::msg_t::init (void* data_, size_t size_, msg_free_fn* ffn_, void* hint, zmq::atomic_counter_t* refcnt_) { if (size_ < max_vsm_size) { int const rc = init_size(size_); if (rc != -1) { memcpy(data(), data_, size_); return 0; } else { return -1; } } else if(refcnt_) { return init_external_storage(data_, size_, refcnt_, ffn_, hint); } else { return init_data(data_, size_, ffn_, hint); } }
/************************************************ 函数名:create_sprite 功能:创建sprite 备注:无 ************************************************/ void UIBlock::create_sprite() { front_sprite = Sprite::create("HelloWorld.png"); mid_sprite = Sprite::create("HelloWorld.png"); back_sprite = Sprite::create("HelloWorld.png"); init_size(Vec2(picture_length, picture_length)); }
Generation* GenerationSpec::init(ReservedSpace rs, int level, GenRemSet* remset) { switch (name()) { case Generation::DefNew: return new DefNewGeneration(rs, init_size(), level); case Generation::ParNew: return new ParNewGeneration(rs, init_size(), level); case Generation::MarkSweepCompact: return new TenuredGeneration(rs, init_size(), level, remset); case Generation::TrainGen: { CardTableRS* ctrs = remset->as_CardTableRS(); if (ctrs == NULL) { vm_exit_during_initialization("Rem set incompatibility."); } // Otherwise return new TrainGeneration(rs, init_size(), level, ctrs); } case Generation::ConcurrentMarkSweep: { assert(UseConcMarkSweepGC, "UseConcMarkSweepGC should be set"); CardTableRS* ctrs = remset->as_CardTableRS(); if (ctrs == NULL) { vm_exit_during_initialization("Rem set incompatibility."); } // Otherwise // The constructor creates the CMSCollector if needed, // else registers with an existing CMSCollector ConcurrentMarkSweepGeneration* g = new ConcurrentMarkSweepGeneration(rs, init_size(), level, ctrs, UseCMSAdaptiveFreeLists, (FreeBlockDictionary::DictionaryChoice)CMSDictionaryChoice); g->initialize_performance_counters(); return g; } default: guarantee(false, "unrecognized GenerationName"); return NULL; } }
void D3D12Render::Set4xMsaaState(bool value) { if(m_4xMsaaState != value) { m_4xMsaaState = value; // Recreate the swapchain and buffers with new multisample settings. init_swapchain(); init_size(); } }
static int init(struct ulo_init *init_args) { int err; init_args->size = init_size(); err = init_args->size; if (err != -1) err = ulo_init(init_args); me = real_bdev; return err; }
/** * Initializes a hashset expecting expected_element size */ void hashset_init_size(HashSet *self, size_t expected_elements) { size_t needed_size; size_t po2size; if(expected_elements >= UINT_MAX/2) { abort(); } needed_size = expected_elements * HT_1_DIV_OCCUPANCY_FLT; po2size = ceil_po2(needed_size); init_size(self, po2size); }
static int display_one_philo(SDL_Surface *screen, t_data *data, int i, Uint32 color) { SDL_Rect pos; t_size size; int bar_size; float food; float philo; philo = data->conf->nb_philo; food = data->conf->nb_food; pos.y = 10; pos.x = 100 + BAR_WIDTH * (i + 1); if (!display_one_empty_bar(screen, init_size(&size, BAR_HEIGHT + 2, BAR_WIDTH), &pos)) return (0); bar_size = data->phi_st[i].eaten_plates * (BAR_HEIGHT / (food / philo)); display_philo_bar(screen, &data->phi_st[i], bar_size, color); return (1); }
/** * Initialializes a hashset with the default size. The memory for the set has to * already allocated. */ void hashset_init(HashSet *self) { init_size(self, HT_MIN_BUCKETS); }
// Alignment void align(size_t alignment) { set_init_size(align_size_up(init_size(), alignment)); set_max_size(align_size_up(max_size(), alignment)); }
void D3D12Render::v_init() { init_d3d(); init_size(); }