Пример #1
0
static void cut_gpa(GPtrArray *dst, GPtrArray *src, gsize keep)
{
	for(int i=0; i<dst->len; i++) g_free(dst->pdata[i]);
	g_ptr_array_set_size(dst, src->len - keep);
	memcpy(&dst->pdata[0], &src->pdata[keep], dst->len * sizeof(void *));
	g_ptr_array_set_size(src, keep);
}
Пример #2
0
static gboolean
gst_gl_mixer_start (GstAggregator * agg)
{
  guint i;
  GstGLMixer *mix = GST_GL_MIXER (agg);
  GstElement *element = GST_ELEMENT (agg);

  if (!GST_AGGREGATOR_CLASS (parent_class)->start (agg))
    return FALSE;

  GST_OBJECT_LOCK (mix);
  mix->array_buffers = g_ptr_array_new_full (element->numsinkpads,
      (GDestroyNotify) _free_glmixer_frame_data);
  mix->frames = g_ptr_array_new_full (element->numsinkpads, NULL);

  g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
  g_ptr_array_set_size (mix->frames, element->numsinkpads);

  for (i = 0; i < element->numsinkpads; i++)
    mix->frames->pdata[i] = g_slice_new0 (GstGLMixerFrameData);

  GST_OBJECT_UNLOCK (mix);

  return TRUE;
}
Пример #3
0
static gboolean
gst_gl_stereo_mix_start (GstAggregator * agg)
{
  guint i;
  GstGLStereoMix *mix = GST_GL_STEREO_MIX (agg);
  GstElement *element = GST_ELEMENT (agg);

  if (!GST_AGGREGATOR_CLASS (parent_class)->start (agg))
    return FALSE;

  GST_OBJECT_LOCK (mix);
  mix->array_buffers = g_ptr_array_new_full (element->numsinkpads,
      (GDestroyNotify) _free_glmixer_frame_data);
  mix->frames = g_ptr_array_new_full (element->numsinkpads, NULL);

  g_ptr_array_set_size (mix->array_buffers, element->numsinkpads);
  g_ptr_array_set_size (mix->frames, element->numsinkpads);

  for (i = 0; i < element->numsinkpads; i++)
    mix->frames->pdata[i] = g_slice_new0 (GstGLStereoMixFrameData);

  mix->viewconvert = gst_gl_view_convert_new ();
  g_object_set (G_OBJECT (mix->viewconvert), "downmix-mode",
      mix->downmix_mode, NULL);

  GST_OBJECT_UNLOCK (mix);

  return TRUE;
}
Пример #4
0
CLFEXP void claro_list_insert(claro_list_t * list, int index, void * data)
{
    GPtrArray *array = (GPtrArray *)list;
    int i; 

    g_return_if_fail(array != NULL); 
          
    if ((index + 1) == array->len) 
    {
        // add to the end of the array 
        g_ptr_array_add (array, data);
        return;
    }
        
    if (index >= array->len)
    {
        // extend and add PAST the end of the array
        g_ptr_array_set_size (array, index + 1);
        array->pdata[index] = data;
        return;
    }
       
    // normal case - shift all elements starting at @index 1 position to the right 

    g_ptr_array_set_size (array, array->len + 1);

    for (i = array->len - 2; i >= index; i--)
        array->pdata[i + 1] = array->pdata[i];

    array->pdata[index] = data;
}
Пример #5
0
static void
gst_rtp_h265_pay_clear_vps_sps_pps (GstRtpH265Pay * rtph265pay)
{
  g_ptr_array_set_size (rtph265pay->vps, 0);
  g_ptr_array_set_size (rtph265pay->sps, 0);
  g_ptr_array_set_size (rtph265pay->pps, 0);
}
Пример #6
0
bool PinyinLookup::get_best_match(PinyinKeyVector keys, CandidateConstraints constraints, MatchResults & results){
    //g_array_set_size(results, 0);

    m_constraints = constraints;
    m_keys = keys;
    int nstep = keys->len + 1;

    //free m_steps_index
    for ( size_t i = 0; i < m_steps_index->len; ++i){
	GHashTable * table = (GHashTable *) g_ptr_array_index(m_steps_index, i);
	g_hash_table_destroy(table);
	g_ptr_array_index(m_steps_index, i) = NULL;
    }

    //free m_steps_content
    for ( size_t i = 0; i < m_steps_content->len; ++i){
	GArray * array = (GArray *) g_ptr_array_index(m_steps_content, i);
	g_array_free(array, TRUE);
	g_ptr_array_index(m_steps_content, i) = NULL;
    }    
    
    //add null start step
    g_ptr_array_set_size(m_steps_index, nstep);
    g_ptr_array_set_size(m_steps_content, nstep);

    for ( size_t i = 0 ; i < nstep; ++i ){
	//initialize m_steps_index
	g_ptr_array_index(m_steps_index, i) = g_hash_table_new(g_direct_hash, g_direct_equal);
	//initialize m_steps_content
	g_ptr_array_index(m_steps_content, i) = g_array_new(FALSE, FALSE, sizeof(lookup_value_t));
    }
    
    lookup_key_t initial_key = sentence_start;
    lookup_value_t initial_value(log(1));
    initial_value.m_handles[1] = sentence_start;
    GArray * initial_step_content = (GArray *) g_ptr_array_index(m_steps_content, 0);
    initial_step_content = g_array_append_val(initial_step_content, initial_value);
    GHashTable * initial_step_index = (GHashTable *) g_ptr_array_index(m_steps_index, 0);
    g_hash_table_insert(initial_step_index, GUINT_TO_POINTER(initial_key), GUINT_TO_POINTER(initial_step_content->len - 1));

#if 0
    LookupStepContent tmp_step = (LookupStepContent) g_ptr_array_index(m_steps_content, 0);
    IBranchIterator * iter = m_winner_tree->get_iterator(tmp_step);
    size_t npinyin = prepare_table_cache(0, keys->len);
    search_unigram(iter, 0, npinyin);
    delete iter;
#endif

    for ( size_t i = 0 ; i < nstep - 1 ; ++i ){
	LookupStepContent tmp_step = (LookupStepContent) g_ptr_array_index(m_steps_content, i);
	IBranchIterator * iter = m_winner_tree->get_iterator(tmp_step);
	size_t npinyin = prepare_table_cache(i, keys->len - i);
	search_bigram(iter, i, npinyin),
	    search_unigram(iter, i, npinyin);
	delete iter;
    }
    return final_step(results);
}
Пример #7
0
/**
 * as_pool_clear_metadata_locations:
 * @pool: An instance of #AsPool.
 *
 * Remove all metadata locations from the list of watched locations.
 */
void
as_pool_clear_metadata_locations (AsPool *pool)
{
	AsPoolPrivate *priv = GET_PRIVATE (pool);

	/* clear arrays */
	g_ptr_array_set_size (priv->xml_dirs, 0);
	g_ptr_array_set_size (priv->yaml_dirs, 0);
	g_ptr_array_set_size (priv->icon_dirs, 0);

	g_debug ("Cleared all metadata search paths.");
}
Пример #8
0
/**
 * nmt_newt_listbox_clear:
 * @listbox: an #NmtNewtListbox
 *
 * Clears the contents of @listbox.
 */
void
nmt_newt_listbox_clear (NmtNewtListbox *listbox)
{
	NmtNewtListboxPrivate *priv = NMT_NEWT_LISTBOX_GET_PRIVATE (listbox);

	g_ptr_array_set_size (priv->entries, 0);
	g_ptr_array_set_size (priv->keys, 0);

	priv->active = -1;
	priv->active_key = NULL;

	nmt_newt_widget_needs_rebuild (NMT_NEWT_WIDGET (listbox));
}
Пример #9
0
static
struct bt_ctf_field *bt_ctf_field_array_create(struct bt_ctf_field_type *type)
{
	struct bt_ctf_field_array *array = g_new0(struct bt_ctf_field_array, 1);
	struct bt_ctf_field_type_array *array_type;
	unsigned int array_length;

	if (!array || !type) {
		goto error;
	}

	array_type = container_of(type, struct bt_ctf_field_type_array, parent);
	array_length = array_type->length;
	array->elements = g_ptr_array_sized_new(array_length);
	if (!array->elements) {
		goto error;
	}

	g_ptr_array_set_free_func(array->elements,
		(GDestroyNotify)bt_ctf_field_put);
	g_ptr_array_set_size(array->elements, array_length);
	return &array->parent;
error:
	g_free(array);
	return NULL;
}
Пример #10
0
void
gum_allocator_probe_detach (GumAllocatorProbe * self)
{
  GumAllocatorProbePrivate * priv = self->priv;
  guint i;

  gum_interceptor_ignore_current_thread (priv->interceptor);

  gum_interceptor_detach_listener (priv->interceptor,
      GUM_INVOCATION_LISTENER (self));

  for (i = 0; i < priv->function_contexts->len; i++)
  {
    FunctionContext * function_ctx = (FunctionContext *)
        g_ptr_array_index (priv->function_contexts, i);
    g_free (function_ctx);
  }

  g_ptr_array_set_size (priv->function_contexts, 0);

  priv->malloc_count = 0;
  priv->realloc_count = 0;
  priv->free_count = 0;

  gum_interceptor_unignore_current_thread (priv->interceptor);
}
Пример #11
0
static gboolean
gst_gl_mixer_process_buffers (GstGLMixer * mix, GstBuffer * outbuf)
{
  GList *walk;
  guint i, array_index = 0;
  GstElement *element = GST_ELEMENT (mix);
  GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix);

  GST_OBJECT_LOCK (mix);
  walk = GST_ELEMENT (mix)->sinkpads;
  i = mix->frames->len;
  g_ptr_array_set_size (mix->frames, element->numsinkpads);
  for (; i < element->numsinkpads; i++)
    mix->frames->pdata[i] = g_slice_new0 (GstGLMixerFrameData);
  while (walk) {                /* We walk with this list because it's ordered */
    GstVideoAggregatorPad *vaggpad = walk->data;

    walk = g_list_next (walk);

    if (vaggpad->buffer != NULL) {
      /* put buffer into array */
      mix->array_buffers->pdata[array_index] = vaggpad->buffer;
    }
    ++array_index;
  }
  GST_OBJECT_UNLOCK (mix);

  return mix_class->process_buffers (mix, mix->array_buffers, outbuf);
}
Пример #12
0
static gboolean prv_cancel_only(const dleyna_task_queue_key_t *queue_id,
				dleyna_task_queue_t *task_queue)
{
	gboolean remove_queue = FALSE;

	if (task_queue->cancelled)
		goto out;

	task_queue->cancelled = TRUE;

	g_ptr_array_foreach(task_queue->tasks, prv_task_cancel_and_free_cb,
			    task_queue);
	g_ptr_array_set_size(task_queue->tasks, 0);

	if (task_queue->idle_id) {
		(void) g_source_remove(task_queue->idle_id);
		task_queue->idle_id = 0;
	}

	if (task_queue->current_task)
		task_queue->task_cancel_cb(task_queue->current_task,
					   task_queue->user_data);
	else
		remove_queue = task_queue->flags &
			DLEYNA_TASK_QUEUE_FLAG_AUTO_REMOVE;

out:

	return remove_queue;
}
Пример #13
0
/* adapted from tm_workspace_find, Anjuta 2.02 */
const GPtrArray *
tm_workspace_find_scoped (const char *name, const char *scope, gint type,
		TMTagAttrType *attrs, gboolean partial, langType lang, gboolean global_search)
{
	static GPtrArray *tags = NULL;

	if ((!theWorkspace))
		return NULL;

	if (tags)
		g_ptr_array_set_size (tags, 0);
	else
		tags = g_ptr_array_new ();

	fill_find_tags_array (tags, theWorkspace->work_object.tags_array,
						  name, scope, type, partial, lang, FALSE);
	if (global_search)
	{
		/* for a scoped tag, I think we always want the same language */
		fill_find_tags_array (tags, theWorkspace->global_tags,
							  name, scope, type, partial, lang, FALSE);
	}
	if (attrs)
		tm_tags_sort (tags, attrs, TRUE);
	return tags;
}
Пример #14
0
RESULT ptrarray_set_size()
{
	GPtrArray *array = g_ptr_array_new();
	guint i, grow_length = 50;
	
	g_ptr_array_add(array, (gpointer)items[0]);
	g_ptr_array_add(array, (gpointer)items[1]);
	g_ptr_array_set_size(array, grow_length);

	if(array->len != grow_length) {
		return FAILED("Array length should be 50, it is %d", array->len);
	} else if(array->pdata[0] != items[0]) {
		return FAILED("Item 0 was overwritten, should be %s", items[0]);
	} else if(array->pdata[1] != items[1]) {
		return FAILED("Item 1 was overwritten, should be %s", items[1]);
	}

	for(i = 2; i < array->len; i++) {
		if(array->pdata[i] != NULL) {
			return FAILED("Item %d is not NULL, it is %p", i, array->pdata[i]);
		}
	}

	g_ptr_array_free(array, TRUE);

	return OK;
}
Пример #15
0
/**
 * internet_address_list_insert:
 * @list: a #InternetAddressList
 * @index: index to insert at
 * @ia: a #InternetAddress
 *
 * Inserts an #InternetAddress into the #InternetAddressList at the
 * specified index.
 **/
void
internet_address_list_insert (InternetAddressList *list, int index, InternetAddress *ia)
{
	char *dest, *src;
	size_t n;
	
	g_return_if_fail (IS_INTERNET_ADDRESS_LIST (list));
	g_return_if_fail (IS_INTERNET_ADDRESS (ia));
	g_return_if_fail (index >= 0);
	
	g_mime_event_add (ia->priv, (GMimeEventCallback) address_changed, list);
	g_object_ref (ia);
	
	if ((guint) index < list->array->len) {
		g_ptr_array_set_size (list->array, list->array->len + 1);
		
		dest = ((char *) list->array->pdata) + (sizeof (void *) * (index + 1));
		src = ((char *) list->array->pdata) + (sizeof (void *) * index);
		n = list->array->len - index - 1;
		
		g_memmove (dest, src, (sizeof (void *) * n));
		list->array->pdata[index] = ia;
	} else {
		/* the easy case */
		g_ptr_array_add (list->array, ia);
	}
	
	g_mime_event_emit (list->priv, NULL);
}
Пример #16
0
static void
_reset_pattern_db_state(void)
{
  pattern_db_forget_state(patterndb);
  g_ptr_array_foreach(messages, (GFunc) log_msg_unref, NULL);
  g_ptr_array_set_size(messages, 0);
}
Пример #17
0
static GPtrArray*
sort_grain_values(GPtrArray *valuedata,
                  guint **nuniqvalues,
                  guint ngrains)
{
    GwyInventory *inventory;
    GPtrArray *sortedvaluedata;
    guint n, i, datasize;

    inventory = gwy_grain_values();
    n = gwy_inventory_get_n_items(inventory);

    sortedvaluedata = g_ptr_array_new();
    g_ptr_array_set_size(sortedvaluedata, n);
    *nuniqvalues = g_new(guint, n);

    datasize = ngrains*sizeof(gdouble);
    for (i = 0; i < n; i++) {
        const gdouble *vdi = g_ptr_array_index(valuedata, i);
        /* +1 to avoid the zeroth non-grain */
        gdouble *svdi = g_memdup(vdi + 1, datasize);

        gwy_math_sort(ngrains, svdi);
        (*nuniqvalues)[i] = uniq_values(svdi, ngrains);
        g_ptr_array_index(sortedvaluedata, i) = svdi;
    }

    return sortedvaluedata;
}
Пример #18
0
/**
 * as_data_pool_set_metadata_locations:
 * @dpool: An instance of #AsDataPool.
 * @dirs: (array zero-terminated=1): a zero-terminated array of data input directories.
 *
 * Set locations for the data pool to read it's data from.
 * This is mainly used for testing purposes. Each location should have an
 * "xmls" and/or "yaml" subdirectory with the actual data as (compressed)
 * AppStream XML or DEP-11 YAML in it.
 */
void
as_data_pool_set_metadata_locations (AsDataPool *dpool, gchar **dirs)
{
	guint i;
	GPtrArray *icondirs;
	AsDataPoolPrivate *priv = GET_PRIVATE (dpool);

	/* clear array */
	g_ptr_array_set_size (priv->mdata_dirs, 0);

	icondirs = g_ptr_array_new_with_free_func (g_free);
	for (i = 0; priv->icon_paths[i] != NULL; i++) {
		g_ptr_array_add (icondirs, g_strdup (priv->icon_paths[i]));
	}

	for (i = 0; dirs[i] != NULL; i++) {
		g_autofree gchar *path = NULL;

		g_ptr_array_add (priv->mdata_dirs, g_strdup (dirs[i]));

		path = g_build_filename (dirs[i], "icons", NULL);
		if (g_file_test (path, G_FILE_TEST_EXISTS))
			g_ptr_array_add (icondirs, g_strdup (path));
	}

	/* add new icon search locations */
	g_strfreev (priv->icon_paths);
	priv->icon_paths = as_ptr_array_to_strv (icondirs);
}
Пример #19
0
/**
 * g_mime_signature_list_insert:
 * @list: a #GMimeSignatureList
 * @index: index to insert at
 * @sig: a #GMimeSignature
 *
 * Inserts a #GMimeSignature into the #GMimeSignatureList at the specified
 * index.
 **/
void
g_mime_signature_list_insert (GMimeSignatureList *list, int index, GMimeSignature *sig)
{
	char *dest, *src;
	size_t n;
	
	g_return_if_fail (GMIME_IS_SIGNATURE_LIST (list));
	g_return_if_fail (GMIME_IS_SIGNATURE (sig));
	g_return_if_fail (index >= 0);
	
	if ((guint) index < list->array->len) {
		g_ptr_array_set_size (list->array, list->array->len + 1);
		
		dest = ((char *) list->array->pdata) + (sizeof (void *) * (index + 1));
		src = ((char *) list->array->pdata) + (sizeof (void *) * index);
		n = list->array->len - index - 1;
		
		g_memmove (dest, src, (sizeof (void *) * n));
		list->array->pdata[index] = sig;
	} else {
		/* the easy case */
		g_ptr_array_add (list->array, sig);
	}
	
	g_object_ref (sig);
}
Пример #20
0
void QueueFace( face_t *face ){
	guint32 i;

	if ( face->d_texture->name[0] == '(' ) {
		g_ptr_array_add( notex_faces, face );
		return;
	}

	for ( i = 0; i < len; i++ )
		if ( sort[i].texture == face->d_texture ) {
			g_ptr_array_add( sort[i].faces, face );
			return;
		}

	if ( len == alloc ) {
		alloc += 8;
		sort = (windingsort_t*)realloc( sort, alloc * sizeof( windingsort_t ) );

		for ( i = len; i < alloc; i++ )
			sort[i].faces = g_ptr_array_new();
	}
	g_ptr_array_set_size( sort[len].faces, 0 );
	g_ptr_array_add( sort[len].faces, face );
	sort[len].texture = face->d_texture;
	len++;
}
Пример #21
0
static GObject*
gwy_string_list_deserialize(const guchar *buffer,
                        gsize size,
                        gsize *position)
{
    gchar **pstr = NULL;
    guint32 len = 0;
    GwySerializeSpec spec[] = {
        { 'S', "strings", &pstr, &len, },
    };
    GwyStringList *strlist;
    GPtrArray *strings;
    guint i;

    g_return_val_if_fail(buffer, NULL);

    if (!gwy_serialize_unpack_object_struct(buffer, size, position,
                                            GWY_STRING_LIST_TYPE_NAME,
                                            G_N_ELEMENTS(spec), spec)) {
        return NULL;
    }

    strlist = gwy_string_list_new();
    strings = (GPtrArray*)strlist->strings;
    g_ptr_array_set_size(strings, len);
    for (i = 0; i < len; i++)
        g_ptr_array_index(strings, i) = pstr[i];
    g_free(pstr);

    return (GObject*)strlist;
}
Пример #22
0
gint LineParse_word(LineParse *lp){
    register guchar *prev, *ptr;
    g_ptr_array_set_size(lp->word, 0);
    switch(LineParse_line(lp)){
        case   0: return 0;
        case EOF: return EOF;
         default: break;
        }
    /* skip start */
    for(ptr = (guchar*)lp->line->str; isspace(*ptr); ptr++);
    prev = ptr;
    while(*ptr){
        if(isspace(*ptr)){
            *ptr = '\0';
            do ptr++; while(isspace(*ptr));
            if(!*ptr)
                break;
            g_ptr_array_add(lp->word, prev); /* add a word */
            prev = ptr;
            }
        ptr++;
        }
    if(prev != ptr)
        g_ptr_array_add(lp->word, prev); /* add final word */
    return lp->word->len;
    }
Пример #23
0
static GPtrArray*
calculate_all_grain_values(GwyDataField *dfield,
                           GwyDataField *mask,
                           guint *ngrains,
                           gint **grains)
{
    GwyGrainValue **gvalues;
    guint xres = dfield->xres, yres = dfield->yres, n, i;
    GwyInventory *inventory;
    GPtrArray *valuedata;

    *grains = g_new0(gint, xres*yres);
    *ngrains = gwy_data_field_number_grains(mask, *grains);

    inventory = gwy_grain_values();
    n = gwy_inventory_get_n_items(inventory);

    valuedata = g_ptr_array_new();
    g_ptr_array_set_size(valuedata, n);

    gvalues = g_new(GwyGrainValue*, n);
    for (i = 0; i < n; i++) {
        gvalues[i] = gwy_inventory_get_nth_item(inventory, i);
        g_ptr_array_index(valuedata, i) = g_new(gdouble, *ngrains + 1);
    }

    gwy_grain_values_calculate(n, gvalues, (gdouble**)valuedata->pdata,
                               dfield, *ngrains, *grains);
    g_free(gvalues);

    return valuedata;
}
Пример #24
0
Property *
object_prop_by_name_type(DiaObject *obj, const char *name, const char *type)
{
  const PropDescription *pdesc;
  GQuark name_quark = g_quark_from_string(name);

  if (!object_complies_with_stdprop(obj)) return NULL;

  for (pdesc = object_get_prop_descriptions(obj);
       pdesc->name != NULL;
       pdesc++) {
    if (name_quark == 0 || (pdesc->quark == name_quark)) {
      Property *prop;
      static GPtrArray *plist = NULL;
      
      if (type && (0 != strcmp(pdesc->type,type))) continue;
      
      if (!plist) {
        plist = g_ptr_array_new();
        g_ptr_array_set_size(plist,1);
      }
      prop = pdesc->ops->new_prop(pdesc,pdtpp_from_object);
      g_ptr_array_index(plist,0) = prop;
      obj->ops->get_props(obj,plist);
      return prop;
    }
  }
  return NULL;
}
/**
 * gst_rtsp_session_media_new:
 * @path: the path
 * @media: (transfer full): the #GstRTSPMedia
 *
 * Create a new #GstRTSPSessionMedia that manages the streams
 * in @media for @path. @media should be prepared.
 *
 * Ownership is taken of @media.
 *
 * Returns: (transfer full): a new #GstRTSPSessionMedia.
 */
GstRTSPSessionMedia *
gst_rtsp_session_media_new (const gchar * path, GstRTSPMedia * media)
{
  GstRTSPSessionMediaPrivate *priv;
  GstRTSPSessionMedia *result;
  guint n_streams;
  GstRTSPMediaStatus status;

  g_return_val_if_fail (path != NULL, NULL);
  g_return_val_if_fail (GST_IS_RTSP_MEDIA (media), NULL);
  status = gst_rtsp_media_get_status (media);
  g_return_val_if_fail (status == GST_RTSP_MEDIA_STATUS_PREPARED || status ==
      GST_RTSP_MEDIA_STATUS_SUSPENDED, NULL);

  result = g_object_new (GST_TYPE_RTSP_SESSION_MEDIA, NULL);
  priv = result->priv;

  priv->path = g_strdup (path);
  priv->path_len = strlen (path);
  priv->media = media;

  /* prealloc the streams now, filled with NULL */
  n_streams = gst_rtsp_media_n_streams (media);
  priv->transports = g_ptr_array_new_full (n_streams, free_session_media);
  g_ptr_array_set_size (priv->transports, n_streams);

  return result;
}
Пример #26
0
static void
nmt_route_table_set_property (GObject      *object,
                              guint         prop_id,
                              const GValue *value,
                              GParamSpec   *pspec)
{
	NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object);
	GPtrArray *array;
	int i;

	switch (prop_id) {
	case PROP_FAMILY:
		priv->family = g_value_get_int (value);
		break;
	case PROP_ROUTES:
		array = g_value_get_boxed (value);
		g_ptr_array_set_size (priv->routes, 0);
		for (i = 0; i < array->len; i++) {
			nm_ip_route_ref (array->pdata[i]);
			g_ptr_array_add (priv->routes, array->pdata[i]);
		}
		nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), priv->routes->len);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Пример #27
0
/**
 * internet_address_list_prepend:
 * @list: a #InternetAddressList
 * @prepend: a #InternetAddressList
 *
 * Inserts all of the addresses in @prepend to the beginning of @list.
 **/
void
internet_address_list_prepend (InternetAddressList *list, InternetAddressList *prepend)
{
	InternetAddress *ia;
	char *dest, *src;
	guint len, i;
	
	g_return_if_fail (IS_INTERNET_ADDRESS_LIST (prepend));
	g_return_if_fail (IS_INTERNET_ADDRESS_LIST (list));
	
	if (prepend->array->len == 0)
		return;
	
	len = prepend->array->len;
	g_ptr_array_set_size (list->array, list->array->len + len);
	
	src = ((char *) list->array->pdata);
	dest = src + (sizeof (void *) * len);
	
	g_memmove (dest, src, (sizeof (void *) * list->array->len));
	
	for (i = 0; i < prepend->array->len; i++) {
		ia = (InternetAddress *) prepend->array->pdata[i];
		g_mime_event_add (ia->priv, (GMimeEventCallback) address_changed, list);
		list->array->pdata[i] = ia;
		g_object_ref (ia);
	}
	
	g_mime_event_emit (list->priv, NULL);
}
Пример #28
0
HPair *HPair_create(Heuristic *heuristic, SubOpt *subopt,
                    gint query_length, gint target_length,
                    gint verbosity, gpointer user_data){
    register HPair *hpair = g_new(HPair, 1);
    g_assert(heuristic);
    g_assert(query_length >= 0);
    g_assert(target_length >= 0);
    hpair->heuristic = Heuristic_share(heuristic);
    hpair->query_length = query_length;
    hpair->target_length = target_length;
    hpair->verbosity = verbosity;
    hpair->user_data = user_data;
    hpair->is_finalised = FALSE;
    /**/
    hpair->portal_data_list = g_ptr_array_new();
    g_assert(heuristic->model->portal_list);
    g_assert(heuristic->model->portal_list->len);
    g_ptr_array_set_size(hpair->portal_data_list,
                         heuristic->model->portal_list->len);
    hpair->bsdp_node_offset = g_new0(gint, heuristic->match_total);
    /* FIXME: merge confirm and update funcs */
    hpair->bsdp = BSDP_create(HPair_confirm_edge_func,
                              HPair_confirm_start_func,
                              HPair_confirm_end_func,
                              HPair_update_edge_func,
                              HPair_update_start_func,
                              HPair_update_end_func,
                              HPair_destroy_node_data_func,
                              HPair_destroy_edge_data_func,
                              hpair);
    hpair->subopt = SubOpt_share(subopt);
    return hpair;
    }
Пример #29
0
static int
untagged_fetch_all (CamelIMAP4Engine *engine, CamelIMAP4Command *ic, guint32 index, camel_imap4_token_t *token, CamelException *ex)
{
	struct imap4_fetch_all_t *fetch = ic->user_data;
	CamelFolderSummary *summary = fetch->summary;
	struct imap4_envelope_t *envelope = NULL;
	GPtrArray *added = fetch->added;
	CamelIMAP4MessageInfo *iinfo;
	CamelMessageInfo *info;
	guint32 changed = 0;
	const char *iuid;
	char uid[12];

	if (index < fetch->first) {
		/* we already have this message envelope cached -
		 * server is probably notifying us of a FLAGS change
		 * by another client? */
		g_assert (index < summary->messages->len);
		iinfo = (CamelIMAP4MessageInfo *)(info = summary->messages->pdata[index - 1]);
		g_assert (info != NULL);
	} else {
		if (index > (added->len + fetch->first - 1))
			g_ptr_array_set_size (added, index - fetch->first + 1);

		if (!(envelope = added->pdata[index - fetch->first])) {
			iinfo = (CamelIMAP4MessageInfo *) (info = camel_message_info_new (summary));
			envelope = g_new (struct imap4_envelope_t, 1);
			added->pdata[index - fetch->first] = envelope;
			envelope->info = info;
			envelope->changed = 0;
		} else {
Пример #30
0
void
egg_graph_widget_key_legend_clear (EggGraphWidget *graph)
{
	EggGraphWidgetPrivate *priv = GET_PRIVATE (graph);
	g_return_if_fail (EGG_IS_GRAPH_WIDGET (graph));
	g_ptr_array_set_size (priv->legend_list, 0);
}