Exemple #1
0
static gint
_alloc_slot_in_matches(RFindNodeState *state)
{
  gint matches_base = 0;

  if (state->stored_matches)
    {
      matches_base = state->stored_matches->len;

      g_array_set_size(state->stored_matches, matches_base + 1);
    }
  return matches_base;
}
Exemple #2
0
static void
_adg_clear(AdgModel *model)
{
    AdgPath *path;
    AdgPathPrivate *data;

    path = (AdgPath *) model;
    data = path->data;

    g_array_set_size(data->cairo.array, 0);
    _adg_clear_operation(path);
    _adg_clear_parent(model);
}
Exemple #3
0
static void 
enumarrayprop_load(EnumarrayProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
  guint nvals = attribute_num_data(attr);
  guint i;
  g_array_set_size(prop->enumarray_data,nvals);

  for (i=0; (i < nvals) && data; i++, data = data_next(data)) 
    g_array_index(prop->enumarray_data,gint,i) = data_enum(data, ctx);
  if (i != nvals) 
    g_warning("attribute_num_data() and actual data count mismatch "
              "(shouldn't happen)");
}
Exemple #4
0
void uat_clear(uat_t* uat) {
    guint i;

    for ( i = 0 ; i < uat->user_data->len ; i++ ) {
        if (uat->free_cb) {
            uat->free_cb(UAT_USER_INDEX_PTR(uat,i));
        }
    }

    for ( i = 0 ; i < uat->raw_data->len ; i++ ) {
        if (uat->free_cb) {
            uat->free_cb(UAT_INDEX_PTR(uat,i));
        }
    }

    g_array_set_size(uat->raw_data,0);
    g_array_set_size(uat->user_data,0);
    g_array_set_size(uat->valid_data,0);

    *((uat)->user_ptr) = NULL;
    *((uat)->nrows_p) = 0;
}
Exemple #5
0
static void
stack_do_window_additions (MetaStack *stack)
{
  GList *tmp;
  gint i, n_added;

  n_added = g_list_length (stack->added);
  if (n_added > 0)
    {
      Window *end;
      int old_size;

      meta_topic (META_DEBUG_STACK,
                  "Adding %d windows to sorted list\n",
                  n_added);

      old_size = stack->xwindows->len;
      g_array_set_size (stack->xwindows, old_size + n_added);

      end = &g_array_index (stack->xwindows, Window, old_size);

      /* stack->added has the most recent additions at the
       * front of the list, so we need to reverse it
       */
      stack->added = g_list_reverse (stack->added);

      i = 0;
      tmp = stack->added;
      while (tmp != NULL)
        {
          MetaWindow *w;

          w = tmp->data;

          end[i] = w->xwindow;

          /* add to the main list */
          stack->sorted = g_list_prepend (stack->sorted, w);

          ++i;
          tmp = tmp->next;
        }

      stack->need_resort = TRUE; /* may not be needed as we add to top */
      stack->need_constrain = TRUE;
      stack->need_relayer = TRUE;
    }

  g_list_free (stack->added);
  stack->added = NULL;
}
Exemple #6
0
void
g_table_resize (GTable *gtable, int rows, int cols)
{
    guint old_len;
    guint new_len;

    if (gtable == NULL)
        return;
    if ((rows < 0) || (cols < 0))
        return;

    old_len = gtable->array->len;
    new_len = rows * cols;

    if (new_len == old_len)
        return;

    /* If shrinking, destroy extra cells */
    if ((new_len < old_len) && gtable->destroyer)
    {
        gchar *entry;
        guint i;

        entry = &gtable->array->data[new_len * gtable->entry_size];
        for (i = new_len; i < old_len; i++)
        {
            gtable->destroyer(entry, gtable->user_data);
            entry += gtable->entry_size;
        }
    }

    /* Change the size */
    g_array_set_size(gtable->array, new_len);

    /* If expanding, construct the new cells */
    if ((new_len > old_len) && gtable->constructor)
    {
        gchar *entry;
        guint i;

        entry = &gtable->array->data[old_len * gtable->entry_size];
        for (i = old_len; i < new_len; i++)
        {
            gtable->constructor(entry, gtable->user_data);
            entry += gtable->entry_size;
        }
    }

    gtable->rows = rows;
    gtable->cols = cols;
}
Exemple #7
0
void gevas_sprite_add_all(       GtkgEvasSprite* ev, GtkgEvasSprite*s)
{
	g_return_if_fail(ev != NULL);
	g_return_if_fail(s  != NULL);
	g_return_if_fail(GTK_IS_GEVAS_SPRITE(ev));
	g_return_if_fail(GTK_IS_GEVAS_SPRITE(s));
	g_return_if_fail(GTK_IS_GEVAS_OBJ_COLLECTION(s ->col));
	g_return_if_fail(GTK_IS_GEVAS_OBJ_COLLECTION(ev->col));

    ev->frame_trans_f_size += eina_list_count( s->col->selected_objs );
    g_array_set_size( ev->frame_trans_f, ev->frame_trans_f_size );
    
    gevas_obj_collection_add_all( ev->col, s->col );
}
Exemple #8
0
void gevas_sprite_add(           GtkgEvasSprite* ev, GtkgEvasSprite_T o )
{
	g_return_if_fail(ev != NULL);
	g_return_if_fail(o  != NULL);
	g_return_if_fail(GTK_IS_GEVAS_SPRITE(ev));
	g_return_if_fail(GTK_IS_GEVASOBJ(o));
	g_return_if_fail(GTK_IS_GEVAS_OBJ_COLLECTION(ev->col));


    ev->frame_trans_f_size++;
    g_array_set_size( ev->frame_trans_f, ev->frame_trans_f_size );
    
    gevas_obj_collection_add( ev->col, o );
}
Exemple #9
0
/**
 * gwy_spectra_clear:
 * @spectra: A spectra object.
 *
 * Removes all spectra from the collection.
 *
 * Since: 2.7
 **/
void
gwy_spectra_clear(GwySpectra *spectra)
{
    guint i;

    g_return_if_fail(GWY_IS_SPECTRA(spectra));

    for (i = 0; i < spectra->spectra->len; i++) {
        GwySpectrum *spec = &g_array_index(spectra->spectra, GwySpectrum, i);

        g_object_unref(spec->ydata);
    }
    g_array_set_size(spectra->spectra, 0);
}
bool get_best_match(PinyinLookup * pinyin_lookup,
                    ChewingKeyVector keys, TokenVector tokens){
    /* initialize constraints. */
    CandidateConstraints constraints = g_array_new
        (FALSE, FALSE, sizeof(lookup_constraint_t));
    g_array_set_size(constraints, keys->len);
    for ( size_t i = 0; i < constraints->len; ++i ) {
        lookup_constraint_t * constraint = &g_array_index
            (constraints, lookup_constraint_t, i);
        constraint->m_type = NO_CONSTRAINT;
    }

    return pinyin_lookup->get_best_match(keys, constraints, tokens);
}
Exemple #11
0
static GArray* Wordlist_selectedToBitmapArray( GArray* a )
{
    GArray* ret = g_array_new( 1, 1, sizeof(gint) );
    ret = g_array_set_size( ret, PATH_MAX+1 );
    
    int i = 0;
    for (i = 0; i < a->len; i++)
    {
        int v = g_array_index (a, gint, i);
        int one = 1;
        g_array_insert_val( ret, v, one );
    }
    return ret;
}
Exemple #12
0
static gboolean find_match(struct srd_decoder_inst *di)
{
	static uint64_t s = 0;
	uint64_t i, j, num_samples_to_process;
	GSList *l, *cond;
	const uint8_t *sample_pos;
	unsigned int num_conditions;

	/* Check whether the condition list is NULL/empty. */
	if (!di->condition_list) {
		srd_dbg("NULL/empty condition list, automatic match.");
		return TRUE;
	}

	/* Check whether we have any non-NULL conditions. */
	if (!have_non_null_conds(di)) {
		srd_dbg("Only NULL conditions in list, automatic match.");
		return TRUE;
	}

	num_samples_to_process = di->abs_end_samplenum - di->abs_cur_samplenum;
	num_conditions = g_slist_length(di->condition_list);

	/* di->match_array is NULL here. Create a new GArray. */
	di->match_array = g_array_sized_new(FALSE, TRUE, sizeof(gboolean), num_conditions);
	g_array_set_size(di->match_array, num_conditions);

	for (i = 0, s = 0; i < num_samples_to_process; i++, s++, (di->abs_cur_samplenum)++) {

		sample_pos = di->inbuf + ((di->abs_cur_samplenum - di->abs_start_samplenum) * di->data_unitsize);

		/* Check whether the current sample matches at least one of the conditions (logical OR). */
		/* IMPORTANT: We need to check all conditions, even if there was a match already! */
		for (l = di->condition_list, j = 0; l; l = l->next, j++) {
			cond = l->data;
			if (!cond)
				continue;
			/* All terms in 'cond' must match (logical AND). */
			di->match_array->data[j] = all_terms_match(di, cond, sample_pos);
		}

		update_old_pins_array(di, sample_pos);

		/* If at least one condition matched we're done. */
		if (at_least_one_condition_matched(di, num_conditions))
			return TRUE;
	}

	return FALSE;
}
Exemple #13
0
/* Remove all icons from the BalsaToolbarModel.
 */
void
balsa_toolbar_model_clear(BalsaToolbarModel * model)
{
    guint j;

    for (j = 0; j < model->current->len; j++) {
        BalsaToolbarEntry *entry;

        entry = &g_array_index(model->current, BalsaToolbarEntry, j);
        g_free(entry->action);
        g_free(entry->icon);
    }
    g_array_set_size(model->current, 0);
}
Exemple #14
0
static BezPointarrayProperty *
bezpointarrayprop_copy(BezPointarrayProperty *src) 
{
  guint i;
  BezPointarrayProperty *prop = 
    (BezPointarrayProperty *)src->common.ops->new_prop(src->common.descr,
                                                        src->common.reason);
  copy_init_property(&prop->common,&src->common);
  g_array_set_size(prop->bezpointarray_data,src->bezpointarray_data->len);
  for (i = 0 ; i < src->bezpointarray_data->len; i++) 
    g_array_index(prop->bezpointarray_data,BezPoint,i) = 
      g_array_index(src->bezpointarray_data,BezPoint,i);
  return prop;
}
Exemple #15
0
static void
swfdec_shape_parser_new_styles (SwfdecShapeParser *parser, SwfdecBits *bits)
{
  guint i, n_fill_styles, n_line_styles;

  swfdec_bits_syncbits (bits);
  if (parser->parse_fill) {
    n_fill_styles = swfdec_bits_get_u8 (bits);
    if (n_fill_styles == 0xff) {
      n_fill_styles = swfdec_bits_get_u16 (bits);
    }
    SWFDEC_LOG ("   n_fill_styles %d", n_fill_styles);
    g_array_set_size (parser->fillstyles, n_fill_styles);
    for (i = 0; i < n_fill_styles && swfdec_bits_left (bits); i++) {
      g_array_index (parser->fillstyles, SwfdecStyle, i).draw = 
	parser->parse_fill (bits, parser->data);
    }

    n_line_styles = swfdec_bits_get_u8 (bits);
    if (n_line_styles == 0xff) {
      n_line_styles = swfdec_bits_get_u16 (bits);
    }
    SWFDEC_LOG ("   n_line_styles %d", n_line_styles);
    g_array_set_size (parser->linestyles, n_line_styles);
    for (i = 0; i < n_line_styles && swfdec_bits_left (bits); i++) {
      g_array_index (parser->linestyles, SwfdecStyle, i).draw = 
	parser->parse_line (bits, parser->data);
    }
  } else {
    /* This is the magic part for DefineFont */
    g_array_set_size (parser->fillstyles, 1);
    g_array_index (parser->fillstyles, SwfdecStyle, 0).draw =
	SWFDEC_DRAW (swfdec_pattern_new_color (0xFFFFFFFF));
  }
  parser->n_fill_bits = swfdec_bits_getbits (bits, 4);
  parser->n_line_bits = swfdec_bits_getbits (bits, 4);
}
Exemple #16
0
JOY_GNUC_HOT
static void
submit(JoyScreen *self)
{
	struct Private *priv = GET_PRIVATE(self);
	// update cursor
	if (priv->cursor && priv->moved) {
		GFX3D_Cursor_Position_Set(priv->cursor,
				priv->x - priv->x_hot,
				priv->y - priv->y_hot);
	}
	// clear exposed areas of the frame buffer
	cairo_region_intersect(priv->expose, priv->area);
	for (gint i = 0; i < cairo_region_num_rectangles(priv->expose); ++i) {
		cairo_rectangle_int_t rect;
		cairo_region_get_rectangle(priv->expose, i, &rect);
		GFX3D_Display_ClearAlpha2D(priv->display, NULL,
				(gpointer)&rect, 0., 0., 0., 0.);
		g_array_append_val(priv->rects, rect);
	}
	if (priv->rects->len) {
		cairo_region_subtract(priv->expose, priv->expose);
#if !CAIRO_HAS_GFX3D_SURFACE
		GFX3D_Display_Cache_Flush(priv->display);
#endif // !CAIRO_HAS_GFX3D_SURFACE
		GFX3D_NATIVE_Display display =
			GFX3D_Display_Get_NATIVE_Display(priv->display);
		GFX3D_NATIVE_Surface surface =
			GFX3D_Display_FrameBuffer_Get_NATIVE_Surface(
					priv->display);
		// copy windows to the frame buffer
		for (GList *node = g_queue_peek_head_link(priv->windows);
				node; node = node->next) {
			JoyBubble *window = node->data;
			joy_gfx3d_window_submit(window, display, surface,
					priv->area);
		}
		// flip the display
		GFX3D_Display_Show_Partial(priv->display,
				(gpointer)priv->rects->data,
				priv->rects->len, 1);
		g_array_set_size(priv->rects, 0);
	} else {
		if (priv->moved && priv->cursor) {
			GFX3D_Display_Show_Ch_Reload(priv->cursor);
		}
	}
	priv->moved = FALSE;
}
static void
gst_rtp_ulpfec_dec_start (GstRtpUlpFecDec * self, GstBufferList * buflist,
    guint8 fec_pt, guint16 lost_seq)
{
  guint fec_packets = 0;
  gsize i;

  g_assert (NULL == self->info_media);
  g_assert (0 == self->info_fec->len);
  g_assert (0 == self->info_arr->len);

  g_array_set_size (self->info_arr, gst_buffer_list_length (buflist));

  for (i = 0;
      i < gst_buffer_list_length (buflist) && !self->lost_packet_from_storage;
      ++i) {
    GstBuffer *buffer = gst_buffer_list_get (buflist, i);
    RtpUlpFecMapInfo *info = RTP_FEC_MAP_INFO_NTH (self, i);

    if (!rtp_ulpfec_map_info_map (gst_buffer_ref (buffer), info))
      g_assert_not_reached ();

    if (fec_pt == gst_rtp_buffer_get_payload_type (&info->rtp)) {
      GST_DEBUG_RTP_PACKET (self, "rtp header (fec)", &info->rtp);

      ++fec_packets;
      if (rtp_ulpfec_buffer_is_valid (&info->rtp)) {
        GST_DEBUG_FEC_PACKET (self, &info->rtp);
        g_ptr_array_add (self->info_fec, GUINT_TO_POINTER (i));
      }
    } else {
      GST_LOG_RTP_PACKET (self, "rtp header (incoming)", &info->rtp);

      if (lost_seq == gst_rtp_buffer_get_seq (&info->rtp)) {
        GST_DEBUG_OBJECT (self, "Received lost packet from from the storage");
        g_list_free (self->info_media);
        self->info_media = NULL;
        self->lost_packet_from_storage = TRUE;
      }
      self->info_media =
          g_list_insert_sorted_with_data (self->info_media,
          GUINT_TO_POINTER (i), _compare_fec_map_info, self);
    }
  }
  if (!self->lost_packet_from_storage) {
    self->fec_packets_received += fec_packets;
    self->fec_packets_rejected += fec_packets - self->info_fec->len;
  }
}
Exemple #18
0
void
_cogl_object_set_user_data (CoglObject *object,
                            CoglUserDataKey *key,
                            void *user_data,
                            CoglUserDataDestroyInternalCallback destroy)
{
  CoglUserDataEntry new_entry;
  CoglUserDataEntry *entry;

  if (user_data)
    {
      new_entry.key = key;
      new_entry.user_data = user_data;
      new_entry.destroy = destroy;
    }
  else
    memset (&new_entry, 0, sizeof (new_entry));

  entry = _cogl_object_find_entry (object, key);
  if (entry)
    {
      if (G_LIKELY (entry->destroy))
        entry->destroy (entry->user_data, object);
    }
  else
    {
      if (G_LIKELY (object->n_user_data_entries <
                    COGL_OBJECT_N_PRE_ALLOCATED_USER_DATA_ENTRIES))
        entry = &object->user_data_entry[object->n_user_data_entries++];
      else
        {
          if (G_UNLIKELY (object->user_data_array == NULL))
            {
              object->user_data_array =
                g_array_new (FALSE, FALSE, sizeof (CoglUserDataEntry));
            }

          g_array_set_size (object->user_data_array,
                            object->user_data_array->len + 1);
          entry =
            &g_array_index (object->user_data_array, CoglUserDataEntry,
                            object->user_data_array->len - 1);

          object->n_user_data_entries++;
        }
    }

  *entry = new_entry;
}
bool PinyinLookup::validate_constraint(CandidateConstraints constraints, PinyinKeyVector m_parsed_keys){
    //resize constraints array
    size_t constraints_length = constraints->len;
    if ( m_parsed_keys->len > constraints_length ){
	g_array_set_size(constraints, m_parsed_keys->len);
	//initialize new element
	for( size_t i = constraints_length; i < m_parsed_keys->len; ++i){
	    lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i);
	    constraint->m_type = NO_CONSTRAINT;
	}
    }else if (m_parsed_keys->len < constraints_length ){
	g_array_set_size(constraints, m_parsed_keys->len);
    }
    
    PinyinKey * pinyin_keys = (PinyinKey *)m_parsed_keys->data;
    
    for ( size_t i = 0; i < constraints->len; ++i){
	lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i);
	if ( constraint->m_type == CONSTRAINT_ONESTEP ){
	    phrase_token_t token = constraint->m_token;
	    m_phrase_index->get_phrase_item(token, m_cache_phrase_item);
	    size_t phrase_length = m_cache_phrase_item.get_phrase_length();
	    //clear too long constraint
	    if ( i + phrase_length > constraints->len ){
		clear_constraint(constraints, i);
		continue;
	    }
	    //clear invalidated pinyin
	    gfloat pinyin_poss = m_cache_phrase_item.get_pinyin_possibility(*m_custom, pinyin_keys + i);
	    if ( pinyin_poss < FLT_EPSILON ){
		clear_constraint(constraints, i);
	    }
	}
    }
    return true;
}
size_t PinyinLookup::prepare_table_cache(int nstep, int total_pinyin){
    //free resources
    for ( size_t i = 0; i < m_table_cache->len; ++i){
	PhraseIndexRanges * ranges = &g_array_index(m_table_cache, PhraseIndexRanges, i);
	destroy_pinyin_lookup(*ranges);
    }
    //g_array_set_size(m_table_cache, 1);
    PinyinKey * pinyin_keys = (PinyinKey *)m_keys->data;
    pinyin_keys += nstep;
    //init resources
    g_array_set_size(m_table_cache, MAX_PHRASE_LENGTH + 1);
    size_t len;
    for ( len = 1; len <= total_pinyin && len <= MAX_PHRASE_LENGTH; ++len){
	PhraseIndexRanges * ranges = &g_array_index(m_table_cache, PhraseIndexRanges, len);
	prepare_pinyin_lookup(*ranges);
	int result = m_pinyin_table->search(len, pinyin_keys, *ranges);
	if (!( result & SEARCH_CONTINUED)){
	    ++len;
	    break;
	}
    }
    g_array_set_size(m_table_cache, std_lite::min(len, (size_t) MAX_PHRASE_LENGTH + 1));
    return m_table_cache->len - 1;
}
static void
reset_array (GArray *array)
{
	gint i = 0;
	gchar *tmp = NULL;

	/* Free stored strings */
	for (i = 0; i < array->len; i++) {
		tmp = g_array_index (array, gchar *, i);
		g_free (tmp);
	}

	/* Force the array size to 0 */
	g_array_set_size (array, 0);
}
Exemple #22
0
static void on_sim_goals_new(const lcm_recv_buf_t *rbuf, const char *channel, const lcmtypes_goal_list_t *msg, void *_user)
{
    RendererGoal *self = (RendererGoal*) _user;

    pthread_mutex_lock(&self->mutex);

    g_array_set_size(self->my_goals,msg->num_goals);
    memcpy(self->my_goals->data,msg->goals,msg->num_goals*sizeof(lcmtypes_goal_t));
    activate_simgoals_transmitter(self);

    pthread_mutex_unlock(&self->mutex);


    viewer_request_redraw(self->viewer);
}
Exemple #23
0
static void
arv_fake_interface_update_device_list (ArvInterface *interface, GArray *device_ids)
{
	ArvInterfaceDeviceIds *ids;

	ids = g_new0 (ArvInterfaceDeviceIds, 1);

	g_array_set_size (device_ids, 0);

	ids->device = g_strdup (ARV_FAKE_DEVICE_ID);
	ids->physical = g_strdup (ARV_FAKE_PHYSICAL_ID);
	ids->address = g_strdup (ARV_FAKE_ADDRESS);

	g_array_append_val (device_ids, ids);
}
Exemple #24
0
int        S57_newCentroid(_S57_geo *geo)
// init or reset
{
    return_if_null(geo);

    // case where an object has multiple centroid (concave poly)
    if (NULL == geo->centroid)
        geo->centroid = g_array_new(FALSE, FALSE, sizeof(pt2));
    else
        geo->centroid = g_array_set_size(geo->centroid, 0);

    geo->centroidIdx = 0;

    return TRUE;
}
Exemple #25
0
static void BSAM_DejaVu_traverse(gint first_pos, gint curr_pos,
                                 gint length, gchar *seq, gint len,
                                 gpointer user_data){
    register BSAM_SeedSet *seedset = user_data;
    gint tpos;
    /* If first_pos is in target, ignore this word */
    if(first_pos > seedset->partition)
        return;
    if(first_pos == curr_pos) /* New word */
        BSAM_SeedSet_empty_current(seedset);
    if(curr_pos < seedset->partition){
        if((!seedset->bsam->saturate_threshold)
        || (seedset->query_pos_list->len <= seedset->query_expect))
           g_array_append_val(seedset->query_pos_list, curr_pos);
    } else {
        /* Collect 2nd list. (only if 1st list not empty) */
        /* Apply saturate threshold here
         * by emptying both lists.
         */
        if(seedset->bsam->saturate_threshold
        &&((seedset->query_pos_list->len
          * seedset->target_pos_list->len)
         > (seedset->query_expect * seedset->target_expect))){
            g_array_set_size(seedset->query_pos_list, 0);
            g_array_set_size(seedset->target_pos_list, 0);
            }
        /* FIXME: also need to apply saturatethreshold
         * to cap size of query_pos_list
         */
        if(seedset->query_pos_list->len){
            tpos = curr_pos - seedset->partition - 1;
            g_array_append_val(seedset->target_pos_list, tpos);
            }
        }
    return;
    }
Exemple #26
0
static void
rig_journal_log (GArray *journal,
                 RigPaintContext *paint_ctx,
                 RutEntity *entity,
                 const CoglMatrix *matrix)
{

  RigJournalEntry *entry;

  g_array_set_size (journal, journal->len + 1);
  entry = &g_array_index (journal, RigJournalEntry, journal->len - 1);

  entry->entity = rut_refable_ref (entity);
  entry->matrix = *matrix;
}
static void
champlain_kinetic_scroll_view_init (ChamplainKineticScrollView *self)
{
  ChamplainKineticScrollViewPrivate *priv = self->priv = GET_PRIVATE (self);

  priv->motion_buffer = g_array_sized_new (FALSE, TRUE,
        sizeof (ChamplainKineticScrollViewMotion), 3);
  g_array_set_size (priv->motion_buffer, 3);
  priv->decel_rate = 1.1f;
  priv->viewport = NULL;

  clutter_actor_set_reactive (CLUTTER_ACTOR (self), TRUE);
  g_signal_connect (self, "button-press-event",
      G_CALLBACK (button_press_event_cb), self);
}
Exemple #28
0
/* Reset expert stats */
static void
expert_stat_reset(void *tapdata)
{
    gint n;
    expert_tapdata_t *etd = (expert_tapdata_t *)tapdata;

    /* Free & reallocate chunk of strings */
    g_string_chunk_free(etd->text);
    etd->text = g_string_chunk_new(100);

    /* Empty each of the arrays */
    for (n=0; n < max_level; n++) {
        g_array_set_size(etd->ei_array[n], 0);
    }
}
/**
 * soup_message_headers_clear:
 * @hdrs: a #SoupMessageHeaders
 *
 * Clears @hdrs.
 **/
void
soup_message_headers_clear (SoupMessageHeaders *hdrs)
{
	SoupHeader *hdr_array = (SoupHeader *)hdrs->array->data;
	int i;

	for (i = 0; i < hdrs->array->len; i++)
		g_free (hdr_array[i].value);
	g_array_set_size (hdrs->array, 0);

	if (hdrs->concat)
		g_hash_table_remove_all (hdrs->concat);

	clear_special_headers (hdrs);
}
Exemple #30
0
void
ops_draw (RenderOpBuilder     *builder,
          const GskQuadVertex  vertex_data[GL_N_VERTICES])
{
  RenderOp *last_op;

  last_op = &g_array_index (builder->render_ops, RenderOp, builder->render_ops->len - 1);
  /* If the previous op was a DRAW as well, we didn't change anything between the two calls,
   * so these are just 2 subsequent draw calls. Same VAO, same program etc.
   * And the offsets into the vao are in order as well, so make it one draw call. */
  if (last_op->op == OP_DRAW)
    {
      /* We allow ourselves a little trick here. We still have to add a CHANGE_VAO op for
       * this draw call so we can add our vertex data there, but we want it to be placed before
       * the last draw call, so we reorder those. */
      RenderOp new_draw;
      new_draw.op = OP_DRAW;
      new_draw.draw.vao_offset = last_op->draw.vao_offset;
      new_draw.draw.vao_size = last_op->draw.vao_size + GL_N_VERTICES;

      last_op->op = OP_CHANGE_VAO;
      memcpy (&last_op->vertex_data, vertex_data, sizeof(GskQuadVertex) * GL_N_VERTICES);

      /* Now add the DRAW */
      g_array_append_val (builder->render_ops, new_draw);
    }
  else
    {
      const gsize n_ops = builder->render_ops->len;
      RenderOp *op;
      gsize offset = builder->buffer_size / sizeof (GskQuadVertex);

      /* We will add two render ops here. */
      g_array_set_size (builder->render_ops, n_ops + 2);

      op = &g_array_index (builder->render_ops, RenderOp, n_ops);
      op->op = OP_CHANGE_VAO;
      memcpy (&op->vertex_data, vertex_data, sizeof(GskQuadVertex) * GL_N_VERTICES);

      op = &g_array_index (builder->render_ops, RenderOp, n_ops + 1);
      op->op = OP_DRAW;
      op->draw.vao_offset = offset;
      op->draw.vao_size = GL_N_VERTICES;
    }

  /* We added new vertex data in both cases so increase the buffer size */
  builder->buffer_size += sizeof (GskQuadVertex) * GL_N_VERTICES;
}