void gtk_codegraph_set_data( GtkCodeGraph *_box, float* _dat, const gchar** _str, size_t _len ){ g_return_if_fail( _box != NULL ); g_return_if_fail( _len == 6 ); gint i=0; for ( i=0; i<_len; ++i ){ _box->priv->data[i] = _box->priv->sum + _dat[i]; _box->priv->dta[i] = _dat[i]; _box->priv->sum += _dat[i]; gdk_color_parse(_str[i], &_box->priv->color[i]); } /*Определимся с типом кода и кол-вом точек для его отрисовки*/ if ( (_dat[0] != 0 ) && (_dat[2] != 0) && ( _dat[4] != 0 ) ){//Код З _box->priv->numPoints = 14; _box->priv->numPointsText = 6; } if ( (_dat[0] != 0 ) && (_dat[2] != 0) && ( _dat[4] == 0 ) ){//Код Ж _box->priv->numPoints = 10; _box->priv->numPointsText = 4; } if ( (_dat[0] != 0 ) && (_dat[2] == 0) && ( _dat[4] == 0 ) ){//Код КЖ _box->priv->numPoints = 6; _box->priv->numPointsText = 2; } _box->priv->points = (GdkPoint*)g_renew(GdkPoint, _box->priv->points, _box->priv->numPoints ); _box->priv->pointsText = (GdkPoint*)g_renew(GdkPoint, _box->priv->pointsText, _box->priv->numPointsText ); gtk_codegraph_calc ( _box ); /*Устанавлдиваем размеры окон и расположение*/ }
static void WordHood_set_word(WordHood *wh, gchar *word, gint len, gint threshold){ register gint i; g_assert(len > 0); g_assert(!(len % wh->wha->advance)); wh->orig_word = word; wh->curr_len = len; if(wh->alloc_len < len){ wh->alloc_len = len; wh->curr_word = g_renew(gchar, wh->curr_word, wh->alloc_len); wh->depth_threshold = g_renew(gint, wh->depth_threshold, wh->alloc_len); wh->depth_threshold = g_renew(gint, wh->depth_threshold, wh->alloc_len); } wh->depth_threshold[wh->curr_len - wh->wha->advance] = threshold; for(i = wh->curr_len-(wh->wha->advance << 1); i >= 0; i -= wh->wha->advance){ wh->depth_threshold[i] = wh->depth_threshold[i+wh->wha->advance] - wh->wha->score_func(wh->wha, word+i+wh->wha->advance, word+i+wh->wha->advance); } return; }
void _gdk_monitor_init (void) { #ifdef HAVE_MONITOR_INFO gint i, index; _gdk_num_monitors = 0; EnumDisplayMonitors (NULL, NULL, count_monitor, (LPARAM) &_gdk_num_monitors); _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, _gdk_num_monitors); index = 0; EnumDisplayMonitors (NULL, NULL, enum_monitor, (LPARAM) &index); _gdk_offset_x = G_MININT; _gdk_offset_y = G_MININT; /* Calculate offset */ for (i = 0; i < _gdk_num_monitors; i++) { _gdk_offset_x = MAX (_gdk_offset_x, -_gdk_monitors[i].rect.x); _gdk_offset_y = MAX (_gdk_offset_y, -_gdk_monitors[i].rect.y); } GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n", _gdk_offset_x, _gdk_offset_y)); /* Translate monitor coords into GDK coordinate space */ for (i = 0; i < _gdk_num_monitors; i++) { _gdk_monitors[i].rect.x += _gdk_offset_x; _gdk_monitors[i].rect.y += _gdk_offset_y; GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d@%+d%+d\n", i, _gdk_monitors[i].rect.width, _gdk_monitors[i].rect.height, _gdk_monitors[i].rect.x, _gdk_monitors[i].rect.y)); } #else HDC hDC; _gdk_num_monitors = 1; _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, 1); _gdk_monitors[0].name = g_strdup ("DISPLAY"); hDC = GetDC (NULL); _gdk_monitors[0].width_mm = GetDeviceCaps (hDC, HORZSIZE); _gdk_monitors[0].height_mm = GetDeviceCaps (hDC, VERTSIZE); ReleaseDC (NULL, hDC); _gdk_monitors[0].rect.x = 0; _gdk_monitors[0].rect.y = 0; _gdk_monitors[0].rect.width = GetSystemMetrics (SM_CXSCREEN); _gdk_monitors[0].rect.height = GetSystemMetrics (SM_CYSCREEN); _gdk_offset_x = 0; _gdk_offset_y = 0; #endif }
static void generateWavePeriod(void) { int waveType = 0; double waveFreq; int i; struct iio_device *trigger = iio_context_find_device(ctx, "hrtimer-1"); unsigned long triggerFreq; long long triggerFreqLL = 0; iio_device_attr_read_longlong(trigger, "frequency", &triggerFreqLL); triggerFreq = triggerFreqLL; /* Set the maximum frequency that user can select to 10% of the input generator frequency. */ if (triggerFreq >= 10) gtk_range_set_range(GTK_RANGE(scale_freq), 0.1, triggerFreq / 10); wave_ampl = gtk_range_get_value(GTK_RANGE(scale_ampl)); wave_offset = gtk_range_get_value(GTK_RANGE(scale_offset)); waveFreq = gtk_range_get_value(GTK_RANGE(scale_freq)); buffer_size = (unsigned int)round(triggerFreq / waveFreq); if (buffer_size < 2) buffer_size = 2; else if (buffer_size > 10000) buffer_size = 10000; current_sample = 0; soft_buffer_ch0 = g_renew(uint8_t, soft_buffer_ch0, buffer_size); gtk_range_set_value(GTK_RANGE(scale_freq), (double)triggerFreq / buffer_size); gtk_widget_queue_draw(scale_freq); if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(btn_sine))) waveType = SINEWAVE; else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(btn_square))) waveType = SQUAREWAVE; else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(btn_triangle))) waveType = TRIANGLE; else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(btn_sawtooth))) waveType = SAWTOOTH; FillSoftBuffer(waveType, soft_buffer_ch0); /* Also generate a preview of the output signal. */ float_soft_buff = g_renew(gfloat, float_soft_buff, 2 * buffer_size); X = g_renew(gfloat, X, 2 * buffer_size); for (i = 0; i < 2 * buffer_size; i++) X[i] = i; for (i = 0; i < 2 * buffer_size; i++) float_soft_buff[i] = soft_buffer_ch0[i % buffer_size] * 3.3 / 256; gtk_databox_graph_remove_all(GTK_DATABOX(databox)); databox_graph = gtk_databox_lines_new((2 * buffer_size), X, float_soft_buff, &color_prev_graph, 2); databox_graph_dots = gtk_databox_points_new((2 * buffer_size), X, float_soft_buff, &color_prev_graph_dots, 5); gtk_databox_graph_add(GTK_DATABOX(databox), databox_graph_dots); gtk_databox_graph_add(GTK_DATABOX(databox), databox_graph); gtk_databox_set_total_limits(GTK_DATABOX(databox), -0.2, (i - 1), 3.5, -0.2); }
gboolean gwy_graph_curve_model_save_curve(GwyGraphCurveModel *gcmodel, GwyGraph *graph, gint index_) { GwyGraphAreaCurve *curve; GwyGraphAreaCurveParams *params; GString *str; gint n; gwy_debug(""); g_return_val_if_fail(GWY_IS_GRAPH_CURVE_MODEL(gcmodel), FALSE); g_return_val_if_fail(GWY_IS_GRAPH(graph), FALSE); n = gwy_graph_get_number_of_curves(graph); if (index_ < 0 || index_ >= n) return FALSE; /* data */ n = gwy_graph_get_data_size(graph, index_); if (n != gcmodel->n) { gcmodel->n = n; gcmodel->xdata = g_renew(gdouble, gcmodel->xdata, n); gcmodel->ydata = g_renew(gdouble, gcmodel->ydata, n); } gwy_graph_get_data(graph, gcmodel->xdata, gcmodel->ydata, index_); /* properties */ str = gwy_graph_get_label(graph, index_); g_string_assign(gcmodel->description, str->str); /* FIXME: direct access */ curve = (GwyGraphAreaCurve*)g_ptr_array_index(graph->area->curves, index_); params = &curve->params; /* XXX FIXME: this now uses some random unitialized memory as the color. * Fix the graph! */ gwy_rgba_from_gdk_color(&gcmodel->color, ¶ms->color); gcmodel->type = GWY_GRAPH_CURVE_HIDDEN; if (params->is_point) gcmodel->type |= GWY_GRAPH_CURVE_POINTS; if (params->is_line) gcmodel->type |= GWY_GRAPH_CURVE_LINE; gcmodel->point_type = params->point_type; gcmodel->point_size = params->point_size; gcmodel->line_style = params->line_style; gcmodel->line_size = params->line_size; return TRUE; }
/* Called for open tags <foo bar="baz"> */ static void signal_parser_start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, gpointer user_data, GError **error) { SignalParserData *data = user_data; if (data->type) { if (data->signal) { if (!strcmp (element_name, "return-type")) { get_type (&data->signal->return_type, element_name, attribute_names, attribute_values, error); } else if (!strcmp (element_name, "parameter")) { ++data->node->n_params; data->node->param_types = g_renew (SomeType, data->node->param_types, data->node->n_params); get_type (&data->node->param_types[data->node->n_params - 1], element_name, attribute_names, attribute_values, error); } } else if (!strcmp (element_name, "signal")) { start_signal (context, element_name, attribute_names, attribute_values, user_data, error); } } else if (!strcmp (element_name, "object") || !strcmp (element_name, "interface")) { start_object (context, element_name, attribute_names, attribute_values, user_data, error); } }
static void prepare (GeglOperation *operation) { GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation); GeglProperties *o = GEGL_PROPERTIES (operation); const Babl *in_format = gegl_operation_get_source_format (operation, "input"); const Babl *format = babl_format ("RGB float"); area->left = area->right = area->top = area->bottom = o->radius; o->user_data = g_renew (gint, o->user_data, o->radius + 1); init_neighborhood_outline (o->neighborhood, o->radius, o->user_data); if (in_format) { if (babl_format_has_alpha (in_format)) format = babl_format ("RGBA float"); } gegl_operation_set_format (operation, "input", format); gegl_operation_set_format (operation, "output", format); }
bool desc_ring_set_size(DescRing *ring, uint32_t size) { int i; if (size < 2 || size > 0x10000 || (size & (size - 1))) { DPRINTF("ERROR: ring[%d] size (%d) not a power of 2 " "or in range [2, 64K]\n", ring->index, size); return false; } for (i = 0; i < ring->size; i++) { g_free(ring->info[i].buf); } ring->size = size; ring->head = ring->tail = 0; ring->info = g_renew(DescInfo, ring->info, size); memset(ring->info, 0, size * sizeof(DescInfo)); for (i = 0; i < size; i++) { ring->info[i].ring = ring; } return true; }
static void _vala_array_add1 (FreeSmartphoneGSMNetworkProvider** array, int* length, int* size, const FreeSmartphoneGSMNetworkProvider* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; *array = g_renew (FreeSmartphoneGSMNetworkProvider, *array, *size); } (*array)[(*length)++] = *value; }
/** * g_closure_set_meta_marshal: (skip) * @closure: a #GClosure * @marshal_data: context-dependent data to pass to @meta_marshal * @meta_marshal: a #GClosureMarshal function * * Sets the meta marshaller of @closure. A meta marshaller wraps * @closure->marshal and modifies the way it is called in some * fashion. The most common use of this facility is for C callbacks. * The same marshallers (generated by <link * linkend="glib-genmarshal">glib-genmarshal</link>) are used * everywhere, but the way that we get the callback function * differs. In most cases we want to use @closure->callback, but in * other cases we want to use some different technique to retrieve the * callback function. * * For example, class closures for signals (see * g_signal_type_cclosure_new()) retrieve the callback function from a * fixed offset in the class structure. The meta marshaller retrieves * the right callback and passes it to the marshaller as the * @marshal_data argument. */ void g_closure_set_meta_marshal (GClosure *closure, gpointer marshal_data, GClosureMarshal meta_marshal) { GClosureNotifyData *notifiers; g_return_if_fail (closure != NULL); g_return_if_fail (meta_marshal != NULL); g_return_if_fail (closure->is_invalid == FALSE); g_return_if_fail (closure->in_marshal == FALSE); g_return_if_fail (closure->meta_marshal == 0); notifiers = closure->notifiers; closure->notifiers = g_renew (GClosureNotifyData, NULL, CLOSURE_N_NOTIFIERS (closure) + 1); if (notifiers) { /* usually the meta marshal will be setup right after creation, so the * g_memmove() should be rare-case scenario */ g_memmove (closure->notifiers + 1, notifiers, CLOSURE_N_NOTIFIERS (closure) * sizeof (notifiers[0])); g_free (notifiers); } closure->notifiers[0].data = marshal_data; closure->notifiers[0].notify = (GClosureNotify) meta_marshal; SET (closure, meta_marshal, 1); }
/* Returns 0 on success. Will copy the key but make a reference to the value. Will clobber an existing entry with the same key iff delete_on_replace!=NULL, and will run delete_on_replace on the old element. Will return -2 if replace=NULL and match was found. */ int owl_dict_insert_element(owl_dict *d, const char *k, void *v, void (*delete_on_replace)(void *old)) { int pos, found; found = _owl_dict_find_pos(d, k, &pos); if (found && delete_on_replace) { delete_on_replace(d->els[pos].v); d->els[pos].v = v; return(0); } else if (found && !delete_on_replace) { return(-2); } else { if (d->size + 1 > d->avail) { int avail = MAX(d->avail * GROWBY, d->size + 1); d->els = g_renew(owl_dict_el, d->els, avail); d->avail = avail; if (d->els==NULL) return(-1); } if (pos!=d->size) { /* shift forward to leave us a slot */ memmove(d->els+pos+1, d->els+pos, sizeof(owl_dict_el)*(d->size-pos)); } d->size++; d->els[pos].k = g_strdup(k); d->els[pos].v = v; return(0); } }
void eventd_core_flags_add(EventdCoreContext *context, GQuark flag) { context->flags = g_renew(GQuark, context->flags, ++context->flags_count + 1); context->flags[context->flags_count-1] = flag; context->flags[context->flags_count] = 0; }
int print_object_tree_command(int argc, char* argv[], GString* output) { char* unparsable; char* path = (argc < 2) ? "" : argv[1]; HSObjectChild oc = { .name = path, .child = hsobject_parse_path_verbose(path, &unparsable, output), }; if (strcmp("", unparsable)) { return HERBST_INVALID_ARGUMENT; } HSTreeInterface intf = { .nth_child = object_nth_child, .data = &oc, .destructor = NULL, .child_count = object_child_count, .append_caption = object_append_caption, }; tree_print_to(&intf, output); return 0; } void hsobject_set_attributes(HSObject* obj, HSAttribute* attributes) { // calculate new size size_t count; for (count = 0; attributes[count].name != NULL; count++) ; obj->attributes = g_renew(HSAttribute, obj->attributes, count); obj->attribute_count = count; memcpy(obj->attributes, attributes, count * sizeof(HSAttribute)); for (int i = 0; i < count; i++) { obj->attributes[i].object = obj; } }
static gboolean gsf_output_memory_expand (GsfOutputMemory *mem, gsf_off_t needed) { gsf_off_t capacity = MAX (mem->capacity, MIN_BLOCK); gsize lcapacity; /* If we need >= MAX_STEP, align to a next multiple of MAX_STEP. * Since MAX_STEP is probably a power of two, this computation * should reduce to "dec, shr, inc, shl", which is probably * quicker then branching. */ if (needed < MAX_STEP) while (capacity < needed) capacity *= 2; else capacity = ((needed - 1) / MAX_STEP + 1) * MAX_STEP; /* Check for overflow: g_renew() casts its parameters to gsize. */ lcapacity = capacity; if ((gsf_off_t) lcapacity != capacity || capacity < 0) { g_warning ("overflow in gsf_output_memory_expand"); return FALSE; } mem->buffer = g_renew (guint8, mem->buffer, lcapacity); mem->capacity = capacity; return TRUE; }
gboolean priorityqueue_push(PriorityQueue *q, gpointer data) { utility_assert(q); if (q->size >= q->heapSize) { q->heapSize *= 2; gpointer *oldheap = q->heap; q->heap = g_renew(gpointer, q->heap, q->heapSize); if (q->heap != oldheap) { _priorityqueue_refresh_map(q); } } gpointer *oldentry = g_hash_table_lookup(q->map, data); if (oldentry != NULL) { gint oldindex = oldentry - q->heap; _priorityqueue_heapify_up(q, _priorityqueue_heapify_down(q, oldindex)); return FALSE; } guint index = q->size; q->heap[index] = data; g_hash_table_insert(q->map, data, q->heap + index); q->size += 1; _priorityqueue_heapify_up(q, index); return TRUE; }
gboolean gst_matroska_track_init_video_context (GstMatroskaTrackContext ** p_context) { GstMatroskaTrackVideoContext *video_context; g_assert (p_context != NULL && *p_context != NULL); /* already set up? (track info might come before track type) */ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_VIDEO) { GST_LOG ("video context already set up"); return TRUE; } /* it better not have been set up as some other track type ... */ if ((*p_context)->type != 0) { g_return_val_if_reached (FALSE); } video_context = g_renew (GstMatroskaTrackVideoContext, *p_context, 1); *p_context = (GstMatroskaTrackContext *) video_context; /* defaults */ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_VIDEO; video_context->display_width = 0; video_context->display_height = 0; video_context->pixel_width = 0; video_context->pixel_height = 0; video_context->asr_mode = 0; video_context->fourcc = 0; video_context->default_fps = 0.0; video_context->earliest_time = GST_CLOCK_TIME_NONE; return TRUE; }
static inline void shrink(void) { if(qsz > MINSZ && qnum < qsz / 4) { const gulong newsz = qsz / 2; gulong i; if(qnum == 0) { qstart = 0; qend = -1; } else if(qstart >= newsz && qend >= newsz) { for(i = 0; i < qnum; ++i) q[i] = q[qstart + i]; qstart = 0; qend = qnum - 1; } else if(qstart >= newsz) { const gulong n = qsz - qstart; for(i = 0; i < n; ++i) q[newsz - n + i] = q[qstart + i]; qstart = newsz - n; } else if(qend >= newsz) { const gulong n = qend + 1 - newsz; for(i = 0; i < n; ++i) q[i] = q[newsz + i]; qend = n - 1; } q = g_renew(XEvent, q, newsz); qsz = newsz; } }
gboolean gst_matroska_track_init_audio_context (GstMatroskaTrackContext ** p_context) { GstMatroskaTrackAudioContext *audio_context; g_assert (p_context != NULL && *p_context != NULL); /* already set up? (track info might come before track type) */ if ((*p_context)->type == GST_MATROSKA_TRACK_TYPE_AUDIO) return TRUE; /* it better not have been set up as some other track type ... */ if ((*p_context)->type != 0) { g_return_val_if_reached (FALSE); } audio_context = g_renew (GstMatroskaTrackAudioContext, *p_context, 1); *p_context = (GstMatroskaTrackContext *) audio_context; /* defaults */ (*p_context)->type = GST_MATROSKA_TRACK_TYPE_AUDIO; audio_context->channels = 1; audio_context->samplerate = 8000; return TRUE; }
void ewmh_add_client(Window win) { g_windows = g_renew(Window, g_windows, g_window_count + 1); g_windows[g_window_count] = win; g_window_count++; ewmh_update_client_list(); ewmh_update_client_list_stacking(); }
void gst_video_multiview_meta_set_n_views (GstVideoMultiviewMeta * mview_meta, guint n_views) { guint i; mview_meta->view_info = g_renew (GstVideoMultiviewViewInfo, mview_meta->view_info, n_views); if (mview_meta->view_info == NULL) { if (n_views > 0) g_warning ("Failed to allocate GstVideoMultiview data"); mview_meta->n_views = 0; return; } /* Make sure new entries are zero */ for (i = mview_meta->n_views; i < n_views; i++) { GstVideoMultiviewViewInfo *info = mview_meta->view_info + i; info->meta_id = 0; info->view_label = GST_VIDEO_MULTIVIEW_VIEW_UNKNOWN; } mview_meta->n_views = n_views; }
void gimp_curve_set_n_samples (GimpCurve *curve, gint n_samples) { g_return_if_fail (GIMP_IS_CURVE (curve)); g_return_if_fail (n_samples >= 256); g_return_if_fail (n_samples <= 4096); if (n_samples != curve->n_samples) { gint i; g_object_freeze_notify (G_OBJECT (curve)); curve->n_samples = n_samples; g_object_notify (G_OBJECT (curve), "n-samples"); curve->samples = g_renew (gdouble, curve->samples, curve->n_samples); for (i = 0; i < curve->n_samples; i++) curve->samples[i] = (gdouble) i / (gdouble) (curve->n_samples - 1); g_object_notify (G_OBJECT (curve), "samples"); if (curve->curve_type == GIMP_CURVE_FREE) curve->identity = TRUE; g_object_thaw_notify (G_OBJECT (curve)); } }
static void gst_clock_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstClock *clock; GstClockPrivate *priv; clock = GST_CLOCK (object); priv = clock->priv; switch (prop_id) { case PROP_WINDOW_SIZE: GST_CLOCK_SLAVE_LOCK (clock); priv->window_size = g_value_get_int (value); priv->window_threshold = MIN (priv->window_threshold, priv->window_size); priv->times = g_renew (GstClockTime, priv->times, 4 * priv->window_size); /* restart calibration */ priv->filling = TRUE; priv->time_index = 0; GST_CLOCK_SLAVE_UNLOCK (clock); break; case PROP_WINDOW_THRESHOLD: GST_CLOCK_SLAVE_LOCK (clock); priv->window_threshold = MIN (g_value_get_int (value), priv->window_size); GST_CLOCK_SLAVE_UNLOCK (clock); break; case PROP_TIMEOUT: gst_clock_set_timeout (clock, g_value_get_uint64 (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
void pager_popup_delay_show(ObPagerPopup *self, gulong msec, gchar *text, guint desk) { guint i; if (screen_num_desktops < self->desks) for (i = screen_num_desktops; i < self->desks; ++i) XDestroyWindow(obt_display, self->wins[i]); if (screen_num_desktops != self->desks) self->wins = g_renew(Window, self->wins, screen_num_desktops); if (screen_num_desktops > self->desks) for (i = self->desks; i < screen_num_desktops; ++i) { XSetWindowAttributes attr; attr.border_pixel = RrColorPixel(ob_rr_theme->osd_border_color); self->wins[i] = XCreateWindow(obt_display, self->popup->bg, 0, 0, 1, 1, ob_rr_theme->obwidth, RrDepth(ob_rr_inst), InputOutput, RrVisual(ob_rr_inst), CWBorderPixel, &attr); XMapWindow(obt_display, self->wins[i]); } self->desks = screen_num_desktops; self->curdesk = desk; popup_delay_show(self->popup, msec, text); }
/** * ags_parameter_grow: * @object_type: the #GType of the object's properties * @params: the #GParameter array * @n_params: location to store new size * @...: a %NULL-terminated list of properties name and value * * Grow parameter array of @object_type object. This function is mainly used to * prepare a #GParameter array to instantiate a new #GObject by using g_object_newv(). * * Returns: the resized GParameter array * * Since: 2.0.0 */ GParameter* ags_parameter_grow(GType object_type, GParameter *params, guint *n_params, ...) { //Thank you gimp GObjectClass *object_class; gchar *param_name; va_list ap; object_class = g_type_class_ref (object_type); va_start(ap, n_params); param_name = va_arg (ap, gchar *); while (param_name) { gchar *error; GParamSpec *pspec; error = NULL; pspec = g_object_class_find_property(object_class, param_name); if (! pspec) { g_warning ("%s: object class `%s' has no property named `%s'", G_STRFUNC, g_type_name (object_type), param_name); break; } if(params != NULL){ params = g_renew (GParameter, params, *n_params + 1); }else{ params = g_new(GParameter, 1); } params[*n_params].name = param_name; params[*n_params].value.g_type = 0; g_value_init (¶ms[*n_params].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); G_VALUE_COLLECT (¶ms[*n_params].value, ap, 0, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error); g_free (error); g_value_unset (¶ms[*n_params].value); break; } *n_params = *n_params + 1; param_name = va_arg (ap, gchar *); } return(params); }
cairo_status_t write_func(void* store, unsigned char* data, unsigned int length) { NOUSED(store); __data_size = length + __data_size; __data_base64 = g_renew(guchar, __data_base64, __data_size); memmove((void*)(__data_base64 + __data_size - length), (void*)data, (size_t)length); return CAIRO_STATUS_SUCCESS; }
static void allocate_empty_segs (PixelRegion *PR) { gint need_num_segs; /* find the maximum possible number of empty segments given the current mask */ need_num_segs = PR->w + 3; if (need_num_segs > max_empty_segs) { max_empty_segs = need_num_segs; empty_segs_n = g_renew (gint, empty_segs_n, max_empty_segs); empty_segs_c = g_renew (gint, empty_segs_c, max_empty_segs); empty_segs_l = g_renew (gint, empty_segs_l, max_empty_segs); } }
static gboolean snra_server_client_io_cb (G_GNUC_UNUSED GIOChannel * source, GIOCondition condition, SnraServerClient * client) { GIOStatus status = G_IO_STATUS_NORMAL; #if 0 g_print ("Got IO callback for client %p w/ condition %u\n", client, (guint) (condition)); #endif if (condition & (G_IO_HUP | G_IO_ERR)) { snra_server_connection_lost (client); return FALSE; } if (condition & G_IO_IN) { gsize bread = 0; if (client->in_bufsize <= client->in_bufavail) { gsize cur_offs = client->in_bufptr - client->in_buf; client->in_bufsize *= 2; g_print ("Growing io_buf to %" G_GSIZE_FORMAT " bytes\n", client->in_bufsize); client->in_buf = g_renew (gchar, client->in_buf, client->in_bufsize); client->in_bufptr = client->in_buf + cur_offs; } status = g_io_channel_read_chars (client->io, client->in_buf + client->in_bufavail, client->in_bufsize - client->in_bufavail, &bread, NULL); if (status == G_IO_STATUS_ERROR) { snra_server_connection_lost (client); } else { g_print ("Collected %" G_GSIZE_FORMAT " bytes to io buf\n", bread); client->in_bufavail += bread; } while (client->in_bufavail > 0 && try_parse_websocket_fragment (client)) { }; if (client->in_buf != client->in_bufptr) { memmove (client->in_buf, client->in_bufptr, client->in_bufavail); client->in_bufptr = client->in_buf; } } if (status == G_IO_STATUS_EOF) { // no more data snra_server_connection_lost (client); return FALSE; } return TRUE; }
HSAttribute* hsattribute_create(HSObject* obj, char* name, char* type_str, GString* output) { struct { char* name; int type; } types[] = { { "bool", HSATTR_TYPE_BOOL }, { "uint", HSATTR_TYPE_UINT }, { "int", HSATTR_TYPE_INT }, { "string", HSATTR_TYPE_STRING }, }; int type = -1; for (int i = 0; i < LENGTH(types); i++) { if (!strcmp(type_str, types[i].name)) { type = types[i].type; break; } } if (type < 0) { g_string_append_printf(output, "Unknown attribute type \"%s\"\n", type_str); return NULL; } size_t count = obj->attribute_count + 1; obj->attributes = g_renew(HSAttribute, obj->attributes, count); obj->attribute_count = count; // initialize object HSAttribute* attr = obj->attributes + count - 1; attr->object = obj; attr->type = type; attr->name = g_strdup(name); attr->on_change = ATTR_ACCEPT_ALL; attr->user_attribute = false; attr->user_data = g_new(HSAttributeValue, 1); switch (type) { case HSATTR_TYPE_BOOL: attr->user_data->b = false; attr->value.b = &attr->user_data->b; break; case HSATTR_TYPE_INT: attr->user_data->i = 0; attr->value.i = &attr->user_data->i; break; case HSATTR_TYPE_UINT: attr->user_data->u = 0; attr->value.u = &attr->user_data->u; break; case HSATTR_TYPE_STRING: attr->user_data->str = g_string_new(""); attr->value.str = &attr->user_data->str; break; default: break; } return attr; }
GParameter * gimp_parameters_append_valist (GType object_type, GParameter *params, gint *n_params, va_list args) { GObjectClass *object_class; gchar *param_name; g_return_val_if_fail (g_type_is_a (object_type, G_TYPE_OBJECT), NULL); g_return_val_if_fail (n_params != NULL, NULL); g_return_val_if_fail (params != NULL || *n_params == 0, NULL); object_class = g_type_class_ref (object_type); param_name = va_arg (args, gchar *); while (param_name) { gchar *error = NULL; GParamSpec *pspec = g_object_class_find_property (object_class, param_name); if (! pspec) { g_warning ("%s: object class `%s' has no property named `%s'", G_STRFUNC, g_type_name (object_type), param_name); break; } params = g_renew (GParameter, params, *n_params + 1); params[*n_params].name = param_name; params[*n_params].value.g_type = 0; g_value_init (¶ms[*n_params].value, G_PARAM_SPEC_VALUE_TYPE (pspec)); G_VALUE_COLLECT (¶ms[*n_params].value, args, 0, &error); if (error) { g_warning ("%s: %s", G_STRFUNC, error); g_free (error); g_value_unset (¶ms[*n_params].value); break; } *n_params = *n_params + 1; param_name = va_arg (args, gchar *); } g_type_class_unref (object_class); return params; }
/*! \brief Add elements to the temporary PATH. * \par Function Description * Check if the temporary #PATH object used when interactively * creating paths has room for additional sections. If not, doubles * its capacity. */ static void path_expand (GschemToplevel *w_current) { PATH *p = w_current->temp_path; if (p->num_sections == p->num_sections_max) { p->num_sections_max *= 2; p->sections = g_renew (PATH_SECTION, p->sections, p->num_sections_max); } }