static void add_kmalloc(const char *func, unsigned long long ptr, unsigned int req, int alloc) { struct func_descr *funcd; struct ptr_descr *ptrd; funcd = find_func(func); if (!funcd) funcd = create_func(func); funcd->total_alloc += alloc; funcd->total_req += req; funcd->current_alloc += alloc; funcd->current_req += req; if (funcd->current_alloc > funcd->max_alloc) funcd->max_alloc = funcd->current_alloc; if (funcd->current_req > funcd->max_req) funcd->max_req = funcd->current_req; ptrd = find_ptr(ptr); if (!ptrd) ptrd = create_ptr(ptr); ptrd->alloc = alloc; ptrd->req = req; ptrd->func = funcd; }
ImageParam::ImageParam(Type t, int d) : OutputImageParam( Internal::Parameter(t, true, d, Internal::make_entity_name(this, "Halide::ImageParam", 'p')), Argument::InputBuffer, Func()) { // We must call create_func() after the super-ctor has completed. func = create_func(); }
Thread* Thread::create(ThreadCreateCallback p_callback,void * p_user,const Settings& p_settings) { if (create_func) { return create_func(p_callback,p_user,p_settings); } return NULL; }
ImageParam::ImageParam(Type t, int d, const std::string &n) : OutputImageParam( Internal::Parameter(t, true, d, n, /* is_explicit_name */ true), Argument::InputBuffer, Func()) { // We must call create_func() after the super-ctor has completed. func = create_func(); }
VisualServer *VisualServer::create() { ERR_FAIL_COND_V(singleton,NULL); if (create_func) return create_func(); return NULL; }
static int _virStorageBackendFileSystemVolBuild(virConnectPtr conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol, virStorageVolDefPtr inputvol) { virStorageBackendBuildVolFrom create_func; int tool_type; if (inputvol) { if (vol->target.encryption != NULL) { virStorageReportError(VIR_ERR_NO_SUPPORT, "%s", _("storage pool does not support " "building encrypted volumes from " "other volumes")); return -1; } create_func = virStorageBackendGetBuildVolFromFunction(vol, inputvol); if (!create_func) return -1; } else if (vol->target.format == VIR_STORAGE_FILE_RAW) { create_func = virStorageBackendCreateRaw; } else if (vol->target.format == VIR_STORAGE_FILE_DIR) { create_func = createFileDir; } else if ((tool_type = virStorageBackendFindFSImageTool(NULL)) != -1) { create_func = virStorageBackendFSImageToolTypeToFunc(tool_type); if (!create_func) return -1; } else { virStorageReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("creation of non-raw images " "is not supported without qemu-img")); return -1; } if (create_func(conn, pool, vol, inputvol, 0) < 0) return -1; return 0; }
//----------------------------------------------------------------------------- // LLUndoBuffer() //----------------------------------------------------------------------------- LLUndoBuffer::LLUndoBuffer( LLUndoAction (*create_func()), S32 initial_count ) { mNextAction = 0; mLastAction = 0; mFirstAction = 0; mOperationID = 0; mNumActions = initial_count; mActions = new LLUndoAction *[initial_count]; //initialize buffer with actions for (S32 i = 0; i < initial_count; i++) { mActions[i] = create_func(); if (!mActions[i]) { llerrs << "Unable to create action for undo buffer" << llendl; } } }
Semaphore *Semaphore::create() { ERR_FAIL_COND_V( !create_func, 0 ); return create_func(); }
Mutex *Mutex::create(bool p_recursive) { ERR_FAIL_COND_V(!create_func, 0); return create_func(p_recursive); }
RWLock *RWLock::create() { ERR_FAIL_COND_V(!create_func, 0); return create_func(); }
/** * Called for creating new popups and refreshing existing ones. */ uiBlock *ui_popup_block_refresh(bContext *C, uiPopupBlockHandle *handle, ARegion *butregion, uiBut *but) { const int margin = UI_POPUP_MARGIN; wmWindow *window = CTX_wm_window(C); ARegion *ar = handle->region; uiBlockCreateFunc create_func = handle->popup_create_vars.create_func; uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func; void *arg = handle->popup_create_vars.arg; uiBlock *block_old = ar->uiblocks.first; uiBlock *block; handle->refresh = (block_old != NULL); BLI_assert(!handle->refresh || handle->can_refresh); #ifdef DEBUG wmEvent *event_back = window->eventstate; #endif /* create ui block */ if (create_func) { block = create_func(C, ar, arg); } else { block = handle_create_func(C, handle, arg); } /* callbacks _must_ leave this for us, otherwise we can't call UI_block_update_from_old */ BLI_assert(!block->endblock); /* ensure we don't use mouse coords here! */ #ifdef DEBUG window->eventstate = NULL; #endif if (block->handle) { memcpy(block->handle, handle, sizeof(uiPopupBlockHandle)); MEM_freeN(handle); handle = block->handle; } else { block->handle = handle; } ar->regiondata = handle; /* set UI_BLOCK_NUMSELECT before UI_block_end() so we get alphanumeric keys assigned */ if (but == NULL) { block->flag |= UI_BLOCK_POPUP; } block->flag |= UI_BLOCK_LOOP; UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); /* defer this until blocks are translated (below) */ block->oldblock = NULL; if (!block->endblock) { UI_block_end_ex( C, block, handle->popup_create_vars.event_xy, handle->popup_create_vars.event_xy); } /* if this is being created from a button */ if (but) { block->aspect = but->block->aspect; ui_popup_block_position(window, butregion, but, block); handle->direction = block->direction; } else { uiSafetyRct *saferct; /* keep a list of these, needed for pulldown menus */ saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct"); saferct->safety = block->safety; BLI_addhead(&block->saferct, saferct); } if (block->flag & UI_BLOCK_RADIAL) { int win_width = UI_SCREEN_MARGIN; int winx, winy; int x_offset = 0, y_offset = 0; winx = WM_window_pixels_x(window); winy = WM_window_pixels_y(window); copy_v2_v2(block->pie_data.pie_center_init, block->pie_data.pie_center_spawned); /* only try translation if area is large enough */ if (BLI_rctf_size_x(&block->rect) < winx - (2.0f * win_width)) { if (block->rect.xmin < win_width) { x_offset += win_width - block->rect.xmin; } if (block->rect.xmax > winx - win_width) { x_offset += winx - win_width - block->rect.xmax; } } if (BLI_rctf_size_y(&block->rect) < winy - (2.0f * win_width)) { if (block->rect.ymin < win_width) { y_offset += win_width - block->rect.ymin; } if (block->rect.ymax > winy - win_width) { y_offset += winy - win_width - block->rect.ymax; } } /* if we are offsetting set up initial data for timeout functionality */ if ((x_offset != 0) || (y_offset != 0)) { block->pie_data.pie_center_spawned[0] += x_offset; block->pie_data.pie_center_spawned[1] += y_offset; UI_block_translate(block, x_offset, y_offset); if (U.pie_initial_timeout > 0) { block->pie_data.flags |= UI_PIE_INITIAL_DIRECTION; } } ar->winrct.xmin = 0; ar->winrct.xmax = winx; ar->winrct.ymin = 0; ar->winrct.ymax = winy; ui_block_calc_pie_segment(block, block->pie_data.pie_center_init); /* lastly set the buttons at the center of the pie menu, ready for animation */ if (U.pie_animation_timeout > 0) { for (uiBut *but_iter = block->buttons.first; but_iter; but_iter = but_iter->next) { if (but_iter->pie_dir != UI_RADIAL_NONE) { BLI_rctf_recenter(&but_iter->rect, UNPACK2(block->pie_data.pie_center_spawned)); } } } } else { /* clip block with window boundary */ ui_popup_block_clip(window, block); /* Avoid menu moving down and losing cursor focus by keeping it at * the same height. */ if (handle->refresh && handle->prev_block_rect.ymax > block->rect.ymax) { float offset = handle->prev_block_rect.ymax - block->rect.ymax; UI_block_translate(block, 0, offset); block->rect.ymin = handle->prev_block_rect.ymin; } handle->prev_block_rect = block->rect; /* the block and buttons were positioned in window space as in 2.4x, now * these menu blocks are regions so we bring it back to region space. * additionally we add some padding for the menu shadow or rounded menus */ ar->winrct.xmin = block->rect.xmin - margin; ar->winrct.xmax = block->rect.xmax + margin; ar->winrct.ymin = block->rect.ymin - margin; ar->winrct.ymax = block->rect.ymax + UI_POPUP_MENU_TOP; UI_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); /* apply scroll offset */ if (handle->scrolloffset != 0.0f) { for (uiBut *bt = block->buttons.first; bt; bt = bt->next) { bt->rect.ymin += handle->scrolloffset; bt->rect.ymax += handle->scrolloffset; } } } if (block_old) { block->oldblock = block_old; UI_block_update_from_old(C, block); UI_blocklist_free_inactive(C, &ar->uiblocks); } /* checks which buttons are visible, sets flags to prevent draw (do after region init) */ ui_popup_block_scrolltest(block); /* adds subwindow */ ED_region_init(ar); /* get winmat now that we actually have the subwindow */ wmGetProjectionMatrix(block->winmat, &ar->winrct); /* notify change and redraw */ ED_region_tag_redraw(ar); ED_region_update_rect(ar); #ifdef DEBUG window->eventstate = event_back; #endif return block; }
void nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc callback, gpointer user_data) { NMDeviceFactory *factory; const GSList *iter; GError *error = NULL; char **path, **paths; g_return_if_fail (factories_by_link == NULL); g_return_if_fail (factories_by_setting == NULL); factories_by_link = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); factories_by_setting = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); /* Register internal factories first */ for (iter = internal_types; iter; iter = iter->next) { GType ftype = (GType) GPOINTER_TO_SIZE (iter->data); factory = (NMDeviceFactory *) g_object_new (ftype, NULL); g_assert (factory); _add_factory (factory, FALSE, "internal", callback, user_data); } paths = read_device_factory_paths (); if (!paths) return; for (path = paths; *path; path++) { GModule *plugin; NMDeviceFactoryCreateFunc create_func; const char *item; item = strrchr (*path, '/'); g_assert (item); plugin = g_module_open (*path, G_MODULE_BIND_LOCAL); if (!plugin) { nm_log_warn (LOGD_HW, "(%s): failed to load plugin: %s", item, g_module_error ()); continue; } if (!g_module_symbol (plugin, "nm_device_factory_create", (gpointer) &create_func)) { nm_log_warn (LOGD_HW, "(%s): failed to find device factory creator: %s", item, g_module_error ()); g_module_close (plugin); continue; } factory = create_func (&error); if (!factory) { nm_log_warn (LOGD_HW, "(%s): failed to initialize device factory: %s", item, NM_G_ERROR_MSG (error)); g_clear_error (&error); g_module_close (plugin); continue; } g_clear_error (&error); if (_add_factory (factory, TRUE, g_module_name (plugin), callback, user_data)) g_module_make_resident (plugin); else g_module_close (plugin); g_object_unref (factory); } g_strfreev (paths); }