コード例 #1
0
ファイル: network-backend.c プロジェクト: yubing84/Atlas-1
int network_backends_remove_unlock(network_backends_t *bs, guint index) {
        int i;
        network_backend_t* item = NULL;
        if (index >= bs->backends->len) {
                g_message("%s:network_backends_remove error,the index is out the length of array", G_STRLOC);
                return -1;
        }
        item = g_ptr_array_index(bs->backends, index);
        if (item != NULL) {
                if (item->connected_clients == 0) {
                        network_backend_free(item);
                        g_ptr_array_remove_index(bs->backends, index);
                } else if (item->connected_clients > 0) {
                        for (i = 0; i < bs->recycle_backends->len; i++) {
                                network_backend_t * b = g_ptr_array_index(bs->recycle_backends, i);
                                if (b->connected_clients == 0) {
                                        network_backend_free(b);
                                        g_ptr_array_remove_index(bs->recycle_backends, i);
                                }
                        }
                        g_ptr_array_add(bs->recycle_backends, item);
                        g_ptr_array_remove_index(bs->backends, index);
                } else {
                        g_message("%s:network_backends_remove error, connected_clients less than 0", G_STRLOC);
                }
        }
        return 0;
}
コード例 #2
0
ファイル: eheap.c プロジェクト: MicBosi/GTS
/**
 * gts_eheap_remove_top:
 * @heap: a #GtsEHeap.
 * @key: a pointer on a gdouble or %NULL.
 *
 * Removes the element at the top of the heap and optionally (if @key is not
 * %NULL) returns the value of its key.
 *
 * Returns: the element at the top of the heap.
 */
gpointer gts_eheap_remove_top (GtsEHeap * heap, gdouble * key)
{
  gpointer root;
  GPtrArray * elts;
  guint len;
  GtsEHeapPair * pair;

  g_return_val_if_fail (heap != NULL, NULL);

  elts = heap->elts; 
  len = elts->len;

  if (len == 0)
    return NULL;
  if (len == 1) {
    pair = g_ptr_array_remove_index (elts, 0);
    root = pair->data;
    if (key) 
      *key = pair->key;
    g_free (pair);
    return root;
  }

  pair = elts->pdata[0];
  root = pair->data;
  if (key) 
    *key = pair->key;
  g_free (pair);
  pair = g_ptr_array_remove_index (elts, len - 1);
  elts->pdata[0] = pair;
  pair->pos = 1;
  sift_down (heap, 1);
  return root;
}
コード例 #3
0
ファイル: pka-manager.c プロジェクト: stieg/perfkit
/**
 * pka_manager_shutdown:
 *
 * Shuts down the manager subsystem and the channels, sources, and listeners
 * registered with it.
 *
 * Returns: None.
 * Side effects: Process armageddon.
 */
void
pka_manager_shutdown (void)
{
	PkaSubscription *subscription;
	PkaChannel *channel;
	gint i;

	G_LOCK(subscriptions);
	for (i = manager.subscriptions->len - 1; i >= 0; --i) {
		subscription = g_ptr_array_index(manager.subscriptions, i);
		pka_subscription_mute(subscription, pka_context_default(), FALSE, NULL);
		pka_subscription_unref(subscription);
		g_ptr_array_remove_index(manager.subscriptions, i);
	}
	G_UNLOCK(subscriptions);

	G_LOCK(channels);
	for (i = manager.channels->len - 1; i >= 0; --i) {
		channel = g_ptr_array_index(manager.channels, i);
		pka_channel_stop(channel, FALSE, NULL);
		g_object_unref(channel);
		g_ptr_array_remove_index(manager.channels, i);
	}
	G_UNLOCK(channels);
}
コード例 #4
0
ファイル: bootchooser.c プロジェクト: mgrzeschik/rauc
static gboolean grub_env_set(GPtrArray *pairs) {
	GSubprocess *sub;
	GError *error = NULL;
	gboolean res = FALSE;

	g_assert_cmpuint(pairs->len, >, 0);
	g_assert_nonnull(r_context()->config->grubenv_path);

	g_ptr_array_insert(pairs, 0, g_strdup("grub-editenv"));
	g_ptr_array_insert(pairs, 1, g_strdup(r_context()->config->grubenv_path));
	g_ptr_array_insert(pairs, 2, g_strdup("set"));
	g_ptr_array_add(pairs, NULL);

	sub = g_subprocess_newv((const gchar * const *)pairs->pdata,
				  G_SUBPROCESS_FLAGS_NONE, &error);
	if (!sub) {
		g_warning("starting grub-editenv failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

	res = g_subprocess_wait_check(sub, NULL, &error);
	if (!res) {
		g_warning("grub-editenv failed: %s", error->message);
		g_clear_error(&error);
		goto out;
	}

out:
	g_ptr_array_remove_index(pairs, pairs->len-1);
	g_ptr_array_remove_index(pairs, 2);
	g_ptr_array_remove_index(pairs, 1);
	g_ptr_array_remove_index(pairs, 0);
	return res;
}
コード例 #5
0
void
rpmhdrs_diff_prnt_diff (struct RpmHeadersDiff *diff)
{
  _gptr_array_reverse (diff->hs_add);
  _gptr_array_reverse (diff->hs_del);
  _gptr_array_reverse (diff->hs_mod_old);
  _gptr_array_reverse (diff->hs_mod_new);

  g_assert (diff->hs_mod_old->len == diff->hs_mod_new->len);

  while (diff->hs_add->len ||
         diff->hs_del->len ||
         diff->hs_mod_old->len)
    {
      if (_rpmhdrs_diff_cmp_end (diff->hs_mod_old, diff->hs_del) < 0)
        if (_rpmhdrs_diff_cmp_end (diff->hs_mod_old, diff->hs_add) < 0)
          { /* mod is first */
            Header hm = diff->hs_mod_old->pdata[diff->hs_mod_old->len-1];

            printf("!");
            pkg_print (hm);
            g_ptr_array_remove_index(diff->hs_mod_old, diff->hs_mod_old->len-1);
            printf("=");
            hm = diff->hs_mod_new->pdata[diff->hs_mod_new->len-1];
            pkg_print (hm);
            g_ptr_array_remove_index(diff->hs_mod_new, diff->hs_mod_new->len-1);
          }
        else
          { /* add is first */
            Header ha = diff->hs_add->pdata[diff->hs_add->len-1];

            printf ("+");
            pkg_print (ha);
            g_ptr_array_remove_index(diff->hs_add, diff->hs_add->len-1);
          }
      else
        if (_rpmhdrs_diff_cmp_end (diff->hs_del, diff->hs_add) < 0)
          { /* del is first */
            Header hd = diff->hs_del->pdata[diff->hs_del->len-1];

            printf ("-");
            pkg_print (hd);
            g_ptr_array_remove_index(diff->hs_del, diff->hs_del->len-1);
          }
        else
          { /* add is first */
            Header ha = diff->hs_add->pdata[diff->hs_add->len-1];

            printf ("+");
            pkg_print (ha);
            g_ptr_array_remove_index(diff->hs_add, diff->hs_add->len-1);
          }
    }

  rpmhdrs_diff_free (diff);
}
コード例 #6
0
ファイル: signals.c プロジェクト: svn2github/irssi
static void signal_remove_from_list(SIGNAL_REC *rec, int signal_id,
				    int list, int index)
{
	if (rec->emitting) {
		g_ptr_array_index(rec->siglist[list], index) = NULL;
		rec->altered = TRUE;
	} else {
		g_ptr_array_remove_index(rec->siglist[list], index);
		g_ptr_array_remove_index(rec->modulelist[list], index);
		if (signal_is_emitlist_empty(rec))
			signal_destroy(signal_id);
	}
}
コード例 #7
0
static bool
_CatalogRemoveCancelNotification(_Catalog *catalog,
                                 LSCancelNotificationFunc function, void *context, LSError *lserror)
{
    bool retVal = false;
    _CatalogLock(catalog);

    if (!catalog->cancel_notify_list)
    {
        _LSErrorSet(lserror, MSGID_LS_CATALOG_ERR, -1, "Cancel notification list not available");
        goto cleanup;
    }

    int idx;
    for (idx = 0; idx < catalog->cancel_notify_list->len; ++idx)
    {
        _SubscriberCancelNotification *scn = g_ptr_array_index(catalog->cancel_notify_list, idx);
        if (scn->function == function && scn->context == context)
        {
            g_ptr_array_remove_index(catalog->cancel_notify_list, idx);
            break;
        }
    }
    retVal = true;

cleanup:
    _CatalogUnlock(catalog);
    return retVal;
}
コード例 #8
0
ファイル: signals.c プロジェクト: svn2github/irssi
/* Remove all NULL functions from signal list */
static void signal_list_clean(SIGNAL_REC *rec)
{
	int n, index;

	for (n = 0; n < SIGNAL_LISTS; n++) {
		if (rec->siglist[n] == NULL)
			continue;

		for (index = rec->siglist[n]->len-1; index >= 0; index--) {
			if (g_ptr_array_index(rec->siglist[n], index) == NULL) {
				g_ptr_array_remove_index(rec->siglist[n], index);
				g_ptr_array_remove_index(rec->modulelist[n], index);
			}
		}
	}
}
コード例 #9
0
ファイル: backlog.c プロジェクト: hiciu/ekg2
void ncurses_backlog_add_real(window_t *w, /*locale*/ fstring_t *str) {
	ncurses_window_t *n = w->priv_data;
	backlog_line_t *b;

	if (!w)
		return;

	/* add line */
	b = xmalloc(sizeof(backlog_line_t));
	b->line = str;
	if (w->nowrap)
		b->height = 1;

	g_ptr_array_add(n->backlog, b);

	/* check backlog length */
	if (n->backlog->len >= config_backlog_size) {
		g_ptr_array_remove_index(n->backlog, 0);

		if (n->index == 0)
			ncurses_backlog_seek_start(n);
		else if (n->index > 0)
			n->index--;
	}

	return;
}
コード例 #10
0
/*
 *  Note: this is a new function added to the API
 *
 *  _ostree_kernel_args_delete:
 *  @kargs: a OstreeKernelArgs instance
 *  @arg: key or key/value pair for deletion
 *  @error: an GError instance
 *
 *  There are few scenarios being handled for deletion:
 *
 *  1: for input arg with a single key(i.e without = for split),
 *  the key/value pair will be deleted if there is only
 *  one value that is associated with the key
 *
 *  2: for input arg wth key/value pair, the specific key
 *  value pair will be deleted from the pointer array
 *  if those exist.
 *
 *  3: If the found key has only one value
 *  associated with it, the key entry in the table will also
 *  be removed, and the key will be removed from order table
 *
 *  Returns: False if an error is set,
 *
 **/
gboolean
_ostree_kernel_args_delete (OstreeKernelArgs *kargs,
                            const char       *arg,
                            GError           **error)
{
  OstreeKernelArgQueryFlag query_flag = 0;
  int value_index;

  if (!_ostree_kernel_arg_query_status (kargs, arg, &query_flag,
                                        FALSE, &value_index, error))
    return FALSE;

  /* We then know the arg can be found and is valid currently */
  g_autofree char *arg_owned = g_strdup (arg);
  split_keyeq (arg_owned);

  GPtrArray *values = g_hash_table_lookup (kargs->table, arg_owned);

  /* This tells us to delete that key directly */
  if (query_flag == OSTREE_KERNEL_ARG_KEY_ONE_VALUE)
    return _ostree_kernel_args_delete_key_entry (kargs, arg_owned, error);
  else if (query_flag == OSTREE_KERNEL_ARG_FOUND_KEY_MULTI_VALUE)
    {
      g_ptr_array_remove_index (values, value_index);
      return TRUE;
    }
  else
    g_assert_not_reached();

}
コード例 #11
0
ファイル: host-service.c プロジェクト: britus/dleyna-renderer
static gboolean prv_remove_client(dlr_host_service_t *host_service,
				  const gchar *client,
				  dlr_host_server_t *server,
				  const gchar *device_if,
				  const gchar *file,
				  dlr_host_file_t *hf)
{
	unsigned int i;
	gboolean retval = FALSE;

	for (i = 0; i < hf->clients->len; ++i)
		if (!strcmp(g_ptr_array_index(hf->clients, i), client))
			break;

	if (i == hf->clients->len)
		goto on_error;

	g_ptr_array_remove_index(hf->clients, i);

	retval = TRUE;

on_error:

	return retval;
}
コード例 #12
0
ファイル: data-model-errors.c プロジェクト: arthurnn/libgda
static gboolean
data_model_errors_remove_row (GdaDataModel *model, gint row, GError **error)
{
	DataModelErrors *imodel;

	g_return_val_if_fail (IS_DATA_MODEL_ERRORS (model), FALSE);
	imodel = (DataModelErrors *) model;
	g_return_val_if_fail (imodel->priv, FALSE);

	if (row >= (gint)imodel->priv->rows->len) {
		gchar *str;
		if (imodel->priv->rows->len > 0)
			str = g_strdup_printf ("Row %d out of range (0-%d)", row,
					       imodel->priv->rows->len - 1);
		else
			str = g_strdup_printf ("Row %d not found (empty data model)", row);
		g_set_error (error, TEST_ERROR, TEST_ERROR_GENERIC, "%s", str);
		g_free (str);
                return FALSE;
        }

	GdaRow *drow;
	drow =  g_ptr_array_index (imodel->priv->rows, row);
	/* remove row from data model */
	g_object_unref (drow);
	g_ptr_array_remove_index (imodel->priv->rows, row);
	gda_data_model_row_removed (model, row);
	
	return TRUE;
}
コード例 #13
0
ファイル: transition.c プロジェクト: samdemers/mkapp
void mk_transition_add(GHashTable*   table,
                       MkTransition* t)
{
    // Find or create the array of transitions for this source state
    GPtrArray* array = g_hash_table_lookup(table, t->src_state);
    if (array == NULL) {
        gchar* src_state = g_strdup(t->src_state);
        array = g_ptr_array_new();
        g_hash_table_insert(table, src_state, array);
    }

    // If a transition already exists for that signal, remove it
    guint i;
    for (i = 0; i < array->len; ++i) {
        MkTransition* t2 = (MkTransition*)g_ptr_array_index(array, i);

        if (!g_strcmp0(t->signal, t2->signal)) {
            g_ptr_array_remove_index(array, i);
            mk_transition_delete(t2);
            break;
        }
    }

    // Add the new transition
    g_ptr_array_add(array, t);
}
コード例 #14
0
ファイル: gb-slider.c プロジェクト: MaX121/gnome-builder
static void
gb_slider_remove (GtkContainer *container,
                  GtkWidget    *widget)
{
  GbSlider *self = (GbSlider *)container;
  GbSliderPrivate *priv = gb_slider_get_instance_private (self);
  GbSliderChild *child;
  gsize i;

  g_assert (GB_IS_SLIDER (self));
  g_assert (GTK_IS_WIDGET (widget));

  for (i = 0; i < priv->children->len; i++)
    {
      child = g_ptr_array_index (priv->children, i);

      if (child->widget == widget)
        {
          gtk_widget_unparent (widget);
          g_ptr_array_remove_index (priv->children, i);
          gtk_widget_queue_resize (GTK_WIDGET (self));
          break;
        }
    }
}
コード例 #15
0
/**
 * camel_imap_response_extract:
 * @store: the store the response came from
 * @response: the response data returned from camel_imap_command
 * @type: the response type to extract
 * @ex: a CamelException
 *
 * This checks that @response contains a single untagged response of
 * type @type and returns just that response data. If @response
 * doesn't contain the right information, the function will set @ex
 * and return %NULL. Either way, @response will be freed and the
 * store's connect_lock released.
 *
 * Return value: the desired response string, which the caller must free.
 **/
char *
camel_imap_response_extract (CamelImapStore *store,
			     CamelImapResponse *response,
			     const char *type,
			     CamelException *ex)
{
	int len = strlen (type), i;
	char *resp;

	len = strlen (type);

	for (i = 0; i < response->untagged->len; i++) {
		resp = response->untagged->pdata[i];
		/* Skip "* ", and initial sequence number, if present */
		strtoul (resp + 2, &resp, 10);
		if (*resp == ' ')
			resp = (char *) imap_next_word (resp);

		if (!g_ascii_strncasecmp (resp, type, len))
			break;
	}

	if (i < response->untagged->len) {
		resp = response->untagged->pdata[i];
		g_ptr_array_remove_index (response->untagged, i);
	} else {
		resp = NULL;
		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE,
				      _("IMAP server response did not contain "
					"%s information"), type);
	}

	camel_imap_response_free (store, response);
	return resp;
}
コード例 #16
0
/**
 * gstyle_palette_remove_at_index:
 * @self: a #GstylePalette
 * @position: A position to remove the #GstyleColor from
 *
 * Try to remove the #GstyleColor at @position from the palette
 *
 * Returns: %TRUE on succes, %FALSE otherwise.
 */
gboolean
gstyle_palette_remove_at_index (GstylePalette  *self,
                                gint            position)
{
  GstyleColor *color;

  g_return_val_if_fail (GSTYLE_IS_PALETTE (self), FALSE);

  if (0 <= position && position < self->colors->len)
    {
      color = GSTYLE_COLOR (g_ptr_array_index (self->colors, position));
      remove_color_to_names_sets (self, color);
      g_ptr_array_remove_index (self->colors, position);
      g_list_model_items_changed (G_LIST_MODEL (self), position, 1, 0);
      gstyle_palette_set_changed (self, TRUE);

      return TRUE;
    }
  else
    {
      g_warning ("Trying to remove a Color in palette '%s' at out-of-bounds position %i in (0, %i)\n",
                 gstyle_palette_get_name (self),
                 position, self->colors->len - 1);

      return FALSE;
     }
}
コード例 #17
0
void
ephy_node_filter_empty (EphyNodeFilter *filter)
{
	int i;
	
	for (i = filter->priv->levels->len - 1; i >= 0; i--)
	{
		GList *list, *l;

		list = g_ptr_array_index (filter->priv->levels, i);

		for (l = list; l != NULL; l = g_list_next (l))
		{
			EphyNodeFilterExpression *exp;

			exp = (EphyNodeFilterExpression *) l->data;

			ephy_node_filter_expression_free (exp);
		}

		g_list_free (list);

		g_ptr_array_remove_index (filter->priv->levels, i);
	}
}
コード例 #18
0
ファイル: leica.c プロジェクト: cbuehler/gwyddion
static void
header_end_element(G_GNUC_UNUSED GMarkupParseContext *context,
                   const gchar *element_name,
                   gpointer user_data,
                   G_GNUC_UNUSED GError **error)
{
    XMLParserData *data;
    LIFElement *element;

    data = (XMLParserData *)user_data;

    // gwy_debug("End name = %s", element_name);
    if (gwy_strequal(element_name, "Element")) {
        element = (LIFElement *)g_ptr_array_index(data->elements,
                                               data->elements->len - 1);
        if (!(element->memid)) {
            gwy_debug("Wrong XML: Element has no MemID");
            err_FILE_TYPE(error, "Leica LIF");
        }
        else {
            g_array_append_val(data->file->elements, *element);
            g_ptr_array_remove_index(data->elements,
                                     data->elements->len - 1);
        }
    }
    user_data = (gpointer)data;
}
コード例 #19
0
static void
ide_async_helper_cb (GObject      *object,
                     GAsyncResult *result,
                     gpointer      user_data)
{
  g_autoptr(GTask) task = user_data;
  GPtrArray *funcs;
  GError *error = NULL;

  g_return_if_fail (G_IS_TASK (task));
  g_return_if_fail (G_IS_TASK (result));

  funcs = g_task_get_task_data (task);

  if (!g_task_propagate_boolean (G_TASK (result), &error))
    {
      g_task_return_error (task, error);
      return;
    }

  g_ptr_array_remove_index (funcs, 0);

  if (funcs->len)
    {
      IdeAsyncStep step;

      step = g_ptr_array_index (funcs, 0);
      step (g_task_get_source_object (task),
            g_task_get_cancellable (task),
            ide_async_helper_cb,
            g_object_ref (task));
    }
  else
    g_task_return_boolean (task, TRUE);
}
コード例 #20
0
static void
ide_omni_search_display_remove_provider (IdeOmniSearchDisplay *self,
                                         IdeSearchProvider    *provider)
{
  guint i;

  g_return_if_fail (IDE_IS_OMNI_SEARCH_DISPLAY (self));
  g_return_if_fail (IDE_IS_SEARCH_PROVIDER (provider));

  for (i = 0; i < self->providers->len; i++)
    {
      ProviderEntry *ptr;

      ptr = g_ptr_array_index (self->providers, i);

      if (ptr->provider == provider)
        {
          IdeOmniSearchGroup *group = ptr->group;

          if (group)
            gtk_container_remove (GTK_CONTAINER (self), GTK_WIDGET (group));
          g_ptr_array_remove_index (self->providers, i);
          return;
        }
    }

  g_warning (_("The provider could not be found."));
}
コード例 #21
0
ファイル: menu.c プロジェクト: 41px/uzbl
static void
remove_from_menu(GArray *argv, guint context) {
    GUI *g = &uzbl.gui;
    MenuItem *mi;
    gchar *name = NULL;
    guint i=0;

    if(!g->menu_items)
        return;

    if(!argv_idx(argv, 0))
        return;
    else
        name = argv_idx(argv, 0);

    for(i=0; i < g->menu_items->len; i++) {
        mi = g_ptr_array_index(g->menu_items, i);

        if((context == mi->context) && !strcmp(name, mi->name)) {
            g_free(mi->name);
            g_free(mi->cmd);
            g_free(mi);
            g_ptr_array_remove_index(g->menu_items, i);
        }
    }
}
コード例 #22
0
/**
 * ggn_account_list_del:
 * @alist: The #GgnAccountList to utilize.
 * @idx: The index of the account to remove from the managed list.
 *
 * Removes a given account at index @idx from the managed list.
 *
 * Returns: void.
 **/
void ggn_account_list_del (GgnAccountList *alist, guint idx) {
  /* check bounds. */
  if (idx >= alist->priv->accounts->len)
    return;

  /* get the account at the given index first. */
  alist->priv->account = g_ptr_array_index (alist->priv->accounts, idx);

  /* remove the account from the pointer array. */
  g_ptr_array_remove_index (alist->priv->accounts, idx);

  /* disconnect the "modified" account signal handler. */
  g_signal_handler_disconnect (G_OBJECT (alist->priv->account),
                               alist->priv->account->priv->handler_modified);

  /* disconnect the "updated" account signal handler. */
  g_signal_handler_disconnect (G_OBJECT (alist->priv->account),
                               alist->priv->account->priv->handler_updated);

  /* unset the account preferences. */
  ggn_account_unset_prefs (alist->priv->account);

  /* free the account object. */
  ggn_account_free (alist->priv->account);
}
コード例 #23
0
ファイル: pk-package-sack.c プロジェクト: coolo/packagekit
/**
 * pk_package_sack_remove_package_by_id:
 * @sack: a valid #PkPackageSack instance
 * @package_id: a package_id descriptor
 *
 * Removes a package reference from the sack. As soon as one package is removed
 * the search is stopped.
 *
 * Return value: %TRUE if the package was removed from the sack
 *
 * Since: 0.5.2
 **/
gboolean
pk_package_sack_remove_package_by_id (PkPackageSack *sack,
				      const gchar *package_id)
{
	PkPackage *package;
	const gchar *id;
	gboolean ret = FALSE;
	guint i;
	GPtrArray *array;

	g_return_val_if_fail (PK_IS_PACKAGE_SACK (sack), FALSE);
	g_return_val_if_fail (package_id != NULL, FALSE);

	array = sack->priv->array;
	for (i=0; i<array->len; i++) {
		package = g_ptr_array_index (array, i);
		id = pk_package_get_id (package);
		if (g_strcmp0 (package_id, id) == 0) {
			g_ptr_array_remove_index (array, i);
			ret = TRUE;
			break;
		}
	}

	return ret;
}
コード例 #24
0
/**
 * gstyle_palette_remove:
 * @self: a #GstylePalette
 * @color: A #GstyleColor
 *
 * Try to remove a #GstyleColor from the palette.
 *
 * Returns: %TRUE on succes, %FALSE otherwise.
 */
gboolean
gstyle_palette_remove (GstylePalette  *self,
                       GstyleColor    *color)
{
  GPtrArray *array;

  g_return_val_if_fail (GSTYLE_IS_PALETTE (self), FALSE);
  g_return_val_if_fail (GSTYLE_IS_COLOR (color), FALSE);

  array = self->colors;
  for (gint i = 0; i < array->len; ++i)
    {
      if (array->pdata[i] == color)
        {
          remove_color_to_names_sets (self, color);
          g_ptr_array_remove_index (array, i);
          g_list_model_items_changed (G_LIST_MODEL (self), i, 1, 0);
          gstyle_palette_set_changed (self, TRUE);

          return TRUE;
        }
    }

  return FALSE;
}
コード例 #25
0
void
egg_data_points_remove_point (EggDataPoints *points,
                              guint          index)
{
    EggDataPointsPrivate *priv;
    GObject *object;

    g_return_if_fail (EGG_IS_DATA_POINTS (points));

    priv = EGG_DATA_POINTS_GET_PRIVATE (points);
    object = G_OBJECT (g_ptr_array_remove_index (priv->x_adjustments, index));
    g_object_unref (object);
    object = G_OBJECT (g_ptr_array_remove_index (priv->y_adjustments, index));
    g_object_unref (object);

    g_signal_emit (points, egg_data_points_signals[POINT_REMOVED], 0, index);
}
コード例 #26
0
/* Helper for parse_braced_component; this will turn a single element array
 * matching /^\d+\.\.\d+$/ into a sequence of numbered array elements. */
static GPtrArray *
expand_braced_sequence(GPtrArray *arr)
{
    char *elt, *p;
    char *l, *r;
    int ldigits, rdigits, ndigits;
    guint64 start, end;
    gboolean leading_zero;

    /* check whether the element matches the pattern */
    /* expand last element of the array only */
    elt = g_ptr_array_index(arr, arr->len-1);
    ldigits = 0;
    for (l = p = elt; *p && g_ascii_isdigit(*p); p++)
	ldigits++;
    if (ldigits == 0)
	return arr;
    if (*(p++) != '.')
	return arr;
    if (*(p++) != '.')
	return arr;
    rdigits = 0;
    for (r = p; *p && g_ascii_isdigit(*p); p++)
	rdigits++;
    if (rdigits == 0)
	return arr;
    if (*p)
	return arr;

    /* we have a match, so extract start and end */
    start = g_ascii_strtoull(l, NULL, 10);
    end = g_ascii_strtoull(r, NULL, 10);
    leading_zero = *l == '0';
    ndigits = MAX(ldigits, rdigits);
    if (start > end)
	return arr;

    /* sanity check.. */
    if (end - start > 100000)
	return arr;

    /* remove last from the array */
    g_ptr_array_remove_index(arr, arr->len - 1);

    /* Add new elements */
    while (start <= end) {
	if (leading_zero) {
	    g_ptr_array_add(arr, g_strdup_printf("%0*ju",
			ndigits, (uintmax_t)start));
	} else {
	    g_ptr_array_add(arr, g_strdup_printf("%ju", (uintmax_t)start));
	}
	start++;
    }

    g_free(elt);
    return arr;
}
コード例 #27
0
/**
 * json_array_remove_element:
 * @array: a #JsonArray
 * @index_: the position of the element to be removed
 *
 * Removes the #JsonNode inside @array at @index_ freeing its allocated
 * resources.
 */
void
json_array_remove_element (JsonArray *array,
                           guint      index_)
{
  g_return_if_fail (array != NULL);
  g_return_if_fail (index_ < array->elements->len);

  json_node_free (g_ptr_array_remove_index (array->elements, index_));
}
コード例 #28
0
ファイル: traceset.c プロジェクト: adannis/lttv
void lttv_traceset_remove(LttvTraceset *s, unsigned i) 
{
	LttvTrace * t;
	g_assert(s->traces->len > i);
	t = (LttvTrace *)s->traces->pdata[i];
	t->ref_count--;
	bt_context_remove_trace(lttv_traceset_get_context(s), t->id);
	g_ptr_array_remove_index(s->traces, i);
}
static gboolean
relabel_recursively (OstreeSePolicy *sepolicy,
                     GFile          *dir,
                     GFileInfo      *dir_info,
                     GPtrArray      *path_parts,
                     GCancellable   *cancellable,
                     GError        **error)
{
  gboolean ret = FALSE;
  g_autoptr(GFileEnumerator) direnum = NULL;

  if (!relabel_one_path (sepolicy, dir, dir_info, path_parts,
                         cancellable, error))
    goto out;

  direnum = g_file_enumerate_children (dir, OSTREE_GIO_FAST_QUERYINFO,
                                       G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                       cancellable, error);
  if (!direnum)
    goto out;
  
  while (TRUE)
    {
      GFileInfo *file_info;
      GFile *child;
      GFileType ftype;

      if (!gs_file_enumerator_iterate (direnum, &file_info, &child,
                                       cancellable, error))
        goto out;
      if (file_info == NULL)
        break;

      g_ptr_array_add (path_parts, (char*)gs_file_get_basename_cached (child));

      ftype = g_file_info_get_file_type (file_info);
      if (ftype == G_FILE_TYPE_DIRECTORY)
        {
          if (!relabel_recursively (sepolicy, child, file_info, path_parts,
                                    cancellable, error))
            goto out;
        }
      else
        {
          if (!relabel_one_path (sepolicy, child, file_info, path_parts,
                                 cancellable, error))
            goto out;
        }

      g_ptr_array_remove_index (path_parts, path_parts->len - 1);
    }

  ret = TRUE;
 out:
  return ret;
}
コード例 #30
0
ファイル: btr.c プロジェクト: eepp/babeltrace
static
void stack_pop(struct stack *stack)
{
	assert(stack);
	assert(stack_size(stack));
	BT_LOGV("Popping from stack: "
		"stack-addr=%p, stack-size-before=%u, stack-size-after=%u",
		stack, stack->entries->len, stack->entries->len - 1);
	g_ptr_array_remove_index(stack->entries, stack->entries->len - 1);
}