Пример #1
0
/**
 * _g_segraph_snapshot_new_blank:
 * @node_array_size: size of node array.
 * @edge_array_size: size of edge array.
 * @create_node_array: whether to create node array or make it %NULL.
 * @create_edge_array: whether to create edge array or make it %NULL.
 *
 * Constructs #GSEGraphSnapshot with two empty or %NULL arrays with given sizes.
 *
 * Returns: new #GSEGraphSnapshot.
 */
static GSEGraphSnapshot*
_g_segraph_snapshot_new_blank (guint node_array_size,
                               guint edge_array_size,
                               gboolean create_node_array,
                               gboolean create_edge_array)
{
  GSEGraphSnapshot* graph;

  graph = g_slice_new (GSEGraphSnapshot);

  if (create_node_array)
  {
    graph->node_array = g_ptr_array_sized_new (node_array_size);
  }
  else
  {
    graph->node_array = NULL;
  }

  if (create_edge_array)
  {
    graph->edge_array = g_ptr_array_sized_new (edge_array_size);
  }
  else
  {
    graph->edge_array = NULL;
  }

  return graph;
}
Пример #2
0
static void
nm_ip4_config_init (NMIP4Config *config)
{
	NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);

	priv->nameservers = g_array_new (FALSE, TRUE, sizeof (guint32));
	priv->wins = g_array_new (FALSE, TRUE, sizeof (guint32));
	priv->domains = g_ptr_array_sized_new (3);
	priv->searches = g_ptr_array_sized_new (3);
}
Пример #3
0
static void
nm_ip6_config_init (NMIP6Config *config)
{
	NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config);

	priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr));
	priv->domains = g_ptr_array_sized_new (3);
	priv->searches = g_ptr_array_sized_new (3);
	priv->gateway_set = FALSE;
}
Пример #4
0
void CSensor_btprox::ConstructL()
{
  RefreshBaseScanIntervalSecs();

  SET_TRAP_OOM(User::LeaveNoMemory());
  iResult = g_ptr_array_sized_new(15); 
  iOldResult = g_ptr_array_sized_new(15);
  UNSET_TRAP_OOM();

  LEAVE_IF_ERROR_OR_SET_SESSION_OPEN(iTimer, iTimer.CreateLocal()); 

  LEAVE_IF_ERROR_OR_SET_SESSION_OPEN(iSocketServ, iSocketServ.Connect());
}
Пример #5
0
mem_block_t * create_mem_block(mem_superblock_t *msb) {
	mem_block_t *mb=g_slice_new(mem_block_t);
//	mb->mem=g_slice_alloc0(msb->size*msb->incremental); // initialize to 0 . If a block is not zero-ed means it is already used/initialized
	int rc=0;
	rc=posix_memalign(&mb->mem, sysconf(_SC_PAGESIZE), msb->size*msb->incremental);
	assert(rc==0);
	mb->used=g_ptr_array_sized_new(msb->incremental);
	mb->free=g_ptr_array_sized_new(msb->incremental);
	int i;
	for (i=0; i<msb->incremental; i++) {
	void *p=mb->mem+msb->size*i;
		g_ptr_array_add(mb->free,p);
	}
	return mb;
}
static void
gucharmap_chartable_accessible_init (GucharmapChartableAccessible *accessible)
{
  GucharmapChartableAccessiblePrivate *priv = GET_PRIVATE (accessible);

  priv->cells = g_ptr_array_sized_new (512);
}
Пример #7
0
/**
 * up_device_get_statistics:
 **/
gboolean
up_device_get_statistics (UpDevice *device, const gchar *type, DBusGMethodInvocation *context)
{
	GError *error;
	GPtrArray *array = NULL;
	GPtrArray *complex;
	UpStatsItem *item;
	GValue *value;
	guint i;

	g_return_val_if_fail (UP_IS_DEVICE (device), FALSE);
	g_return_val_if_fail (type != NULL, FALSE);

	/* doesn't even try to support this */
	if (!device->priv->has_statistics) {
		error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "device does not support getting stats");
		dbus_g_method_return_error (context, error);
		goto out;
	}

	/* get the correct data */
	if (g_strcmp0 (type, "charging") == 0)
		array = up_history_get_profile_data (device->priv->history, TRUE);
	else if (g_strcmp0 (type, "discharging") == 0)
		array = up_history_get_profile_data (device->priv->history, FALSE);

	/* maybe the device doesn't support histories */
	if (array == NULL) {
		error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "device has no statistics");
		dbus_g_method_return_error (context, error);
		goto out;
	}

	/* always 101 items of data */
	if (array->len != 101) {
		error = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, "statistics invalid as have %i items", array->len);
		dbus_g_method_return_error (context, error);
		goto out;
	}

	/* copy data to dbus struct */
	complex = g_ptr_array_sized_new (array->len);
	for (i=0; i<array->len; i++) {
		item = (UpStatsItem *) g_ptr_array_index (array, i);
		value = g_new0 (GValue, 1);
		g_value_init (value, UP_DBUS_STRUCT_DOUBLE_DOUBLE);
		g_value_take_boxed (value, dbus_g_type_specialized_construct (UP_DBUS_STRUCT_DOUBLE_DOUBLE));
		dbus_g_type_struct_set (value,
					0, up_stats_item_get_value (item),
					1, up_stats_item_get_accuracy (item), -1);
		g_ptr_array_add (complex, g_value_get_boxed (value));
		g_free (value);
	}

	dbus_g_method_return (context, complex);
out:
	if (array != NULL)
		g_ptr_array_unref (array);
	return TRUE;
}
Пример #8
0
/* Create the filetypes array and fill it with the known filetypes.
 * Warning: GTK isn't necessarily initialized yet. */
void filetypes_init_types(void)
{
	filetype_id ft_id;
	gchar *f;

	g_return_if_fail(filetypes_array == NULL);
	g_return_if_fail(filetypes_hash == NULL);

	filetypes_array = g_ptr_array_sized_new(GEANY_MAX_BUILT_IN_FILETYPES);
	filetypes_hash = g_hash_table_new(g_str_hash, g_str_equal);

	/* Create built-in filetypes */
	for (ft_id = 0; ft_id < GEANY_MAX_BUILT_IN_FILETYPES; ft_id++)
	{
		filetypes[ft_id] = filetype_new();
	}
	init_builtin_filetypes();

	/* Add built-in filetypes to the hash now the name fields are set */
	for (ft_id = 0; ft_id < GEANY_MAX_BUILT_IN_FILETYPES; ft_id++)
	{
		filetype_add(filetypes[ft_id]);
	}
	init_custom_filetypes(app->datadir);
	f = g_build_filename(app->configdir, GEANY_FILEDEFS_SUBDIR, NULL);
	init_custom_filetypes(f);
	g_free(f);

	/* sort last instead of on insertion to prevent exponential time */
	filetypes_by_title = g_slist_sort_with_data(filetypes_by_title,
		cmp_filetype, GINT_TO_POINTER(FALSE));

	read_filetype_config();
}
Пример #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
static void
gum_darwin_mapper_init_dependencies (GumDarwinMapper * self)
{
  GumDarwinModule * module = self->module;
  GPtrArray * dependencies;
  guint i;

  self->dependencies = g_ptr_array_sized_new (5);

  if (self->parent == NULL)
  {
    self->mappings = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
        (GDestroyNotify) gum_darwin_mapping_free);
    gum_darwin_mapper_add_pending_mapping (self, module->name, self);
    gum_darwin_enumerate_modules (module->task,
        gum_darwin_mapper_add_existing_mapping_from_module, self);
  }

  dependencies = module->dependencies;
  for (i = 0; i != dependencies->len; i++)
  {
    GumDarwinMapping * dependency;

    dependency = gum_darwin_mapper_resolve_dependency (self,
        g_ptr_array_index (dependencies, i));
    g_ptr_array_add (self->dependencies, dependency);
  }
}
Пример #11
0
static void
register_archive (GType command_type)
{
	if (Registered_Archives == NULL)
		Registered_Archives = g_ptr_array_sized_new (5);
	g_ptr_array_add (Registered_Archives, fr_registered_archive_new (command_type));
}
Пример #12
0
static void
alias_updated_cb (ExampleContactListManager *manager,
                  TpHandle contact,
                  ExampleContactListConnection *self)
{
  GPtrArray *aliases;
  GValueArray *pair;

  pair = g_value_array_new (2);
  g_value_array_append (pair, NULL);
  g_value_array_append (pair, NULL);
  g_value_init (pair->values + 0, G_TYPE_UINT);
  g_value_init (pair->values + 1, G_TYPE_STRING);
  g_value_set_uint (pair->values + 0, contact);
  g_value_set_string (pair->values + 1,
      example_contact_list_manager_get_alias (manager, contact));

  aliases = g_ptr_array_sized_new (1);
  g_ptr_array_add (aliases, pair);

  tp_svc_connection_interface_aliasing_emit_aliases_changed (self, aliases);

  g_ptr_array_free (aliases, TRUE);
  g_value_array_free (pair);
}
Пример #13
0
void	ug_category_list_link (GList* list, GList* download_list)
{
	UgCategoryAddFunc	add_func;
	GPtrArray*	array;
	UgCategory*	category;
	GList*		link;
	guint		index;

	// create array from download_list
	array = g_ptr_array_sized_new (g_list_length (download_list));
	for (link = download_list;  link;  link = link->next)
		array->pdata[array->len++] = link->data;

	// link tasks in category
	for (;  list;  list = list->next) {
		category = list->data;
		add_func = category->funcs->add;
		// get tasks from array by index
		for (link = category->indices;  link;  link = link->next) {
			index = GPOINTER_TO_INT (link->data);
			if (index < array->len)
				add_func (category, g_ptr_array_index (array, index));
		}
		// free list
		g_list_free (category->indices);
		category->indices = NULL;
	}

	// free array
	g_ptr_array_free (array, TRUE);
}
Пример #14
0
static gboolean
modify_edit_end(GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
  GtkTextView *view = GTK_TEXT_VIEW(widget);
  DiaObject *obj = (DiaObject*)data;
  GQuark quark = g_quark_from_string(PROP_TYPE_TEXT);
  const PropDescription *props = obj->ops->describe_props(obj);
  int i;

  printf("Ending focus\n");

  for (i = 0; props[i].name != NULL; i++) {
    printf("Testing to remove: %s\n", props[i].name);
    if (props[i].type_quark == quark) {
      GPtrArray *textprops = g_ptr_array_sized_new(1);
      TextProperty *textprop;
      Property *prop = props[i].ops->new_prop(&props[i], pdtpp_true);
      GtkTextBuffer *buf;
      GtkTextIter start, end;

      printf("Going to stop %d\n", i);
      buf = gtk_text_view_get_buffer(view);
      g_ptr_array_add(textprops, prop);
      obj->ops->get_props(obj, textprops);
      textprop = (TextProperty*)prop;
      if (textprop->text_data != NULL) g_free(textprop->text_data);
      gtk_text_buffer_get_bounds(buf, &start, &end);
      textprop->text_data = gtk_text_buffer_get_text(buf, &start, &end, TRUE);
      printf("Setting text %s\n", textprop->text_data);
      obj->ops->set_props(obj, textprops);
      gtk_widget_destroy(widget);
    }
  }
  return FALSE;
}
Пример #15
0
static void *correct_thread(void *data) {
	correct_aux_t *d = (correct_aux_t*) data;
	int i = 0;
	bwa_seq_t *s = NULL, *query = NULL, *seqs = d->ht->seqs;
	readarray *low_kmer_reads = d->low_kmer_reads;
	alignarray *aligns = NULL;

	aligns = g_ptr_array_sized_new(N_DEFAULT_ALIGNS);
	for (i = d->start; i < d->end; i++) {
		if (i % 10000 == 0)
			show_msg(__func__,
					"Thread %d correction progress: [%d,%d,%d]... \n", d->tid,
					d->start, i, d->end);
		s = g_ptr_array_index(low_kmer_reads, i);
		if (is_repetitive_q(s)) {
			s->status = USED;
			continue;
		}
		// Only the fresh reads, or the reads tried once would be corrected.
		if (s->status != FRESH)
			continue;
		query = new_seq(s, s->len - 8, 0);
		pe_aln_query(s, s->seq, d->ht, MISMATCHES, s->len, 0, aligns);
		pe_aln_query(s, s->rseq, d->ht, MISMATCHES, s->len, 1, aligns);
		if (aligns->len >= 4)
			correct_bases(seqs, s, aligns, d->tid);
		s->status = TRIED;
		reset_alg(aligns);
		bwa_free_read_seq(1, query);
		//if (i > 10000)
		//	break;
	}
	free_alg(aligns);
	show_msg(__func__, "Thread %d finished. \n", d->tid);
}
Пример #16
0
static int
init_srvinfo(const gchar *sid, service_info_t *si)
{
	GMatchInfo *mi = NULL;

	if (!g_regex_match(regex_svc, sid, 0, &mi)) {
		g_printerr("Unrecognized pattern for service id [%s]\n", sid);
		return -1;
	} else {
		gchar *str_ns, *str_type, *str_addr;

		str_ns = g_match_info_fetch(mi, 1);
		str_type = g_match_info_fetch(mi, 2);
		str_addr = g_match_info_fetch(mi, 3);
		g_free(mi);
		g_strlcpy(si->type, str_type, sizeof(si->type)-1);
		g_free(str_type);
		g_strlcpy(si->ns_name, str_ns, sizeof(si->ns_name)-1);
		g_free(str_ns);
		if (!l4_address_init_with_url(&(si->addr), str_addr, NULL)) {
			g_printerr("Invalid service address [%s]", str_addr);
			return -1;
		}

		g_free(str_addr);
	}

	if (!si->tags)
		si->tags = g_ptr_array_sized_new(6);

	return 0;
}
Пример #17
0
Encodings *encodings_load(void)
{
    char *filename = options_file_build_filename("Encodings", NULL);

    if (filename)
    {
        GKeyFile *kf = options_file_open("Encodings", encodings_group_name);
        int count = options_file_lookup_int_with_default(kf,
            encodings_group_name, "n", 0);
        GPtrArray *enc = g_ptr_array_sized_new(count);
        int n;

        for (n = 0; n < count; ++n)
        {
            char *v = options_file_lookup_string_with_default(kf,
                    encodings_group_name, encodings_get_key(n), NULL);

            g_ptr_array_add(enc, v);
        }
        g_free(filename);
        g_key_file_free(kf);
        g_ptr_array_sort(enc, (GCompareFunc) encodings_compare);
        return enc;
    }
    else
    {
        return encodings_build_default();
    }
}
gint riglist_get_names(GPtrArray **list)
{
	gint i, len;

	if (riglist == NULL)
		riglist_get_list();

	if (rignames != NULL) {
		*list = rignames;
		return g_slist_length(riglist);
	}

	len = g_slist_length(riglist);

	rignames = g_ptr_array_sized_new(len);

	for (i = 0; i < len; i++) {
		struct rig_caps *rig = g_slist_nth_data(riglist, i);
		gchar *name;

		name = g_strdup_printf("%s %s",
				       rig->mfg_name,
				       rig->model_name);

		g_ptr_array_add(rignames, (gpointer) name);
	}

	*list = rignames;
	return len;
}
Пример #19
0
void
ipc_endpoint_connect_to_socket(ipc_endpoint_t *ipc, int sock)
{
    g_assert(ipc);
    g_assert(ipc->status == IPC_ENDPOINT_DISCONNECTED);

    ipc_recv_state_t *state = &ipc->recv_state;
    state->queued_ipcs = g_ptr_array_new();

    GIOChannel *channel = g_io_channel_unix_new(sock);
    g_io_channel_set_encoding(channel, NULL, NULL);
    g_io_channel_set_buffered(channel, FALSE);
    state->watch_in_id = g_io_add_watch(channel, G_IO_IN, (GIOFunc)ipc_recv, ipc);
    state->watch_hup_id = g_io_add_watch(channel, G_IO_HUP, (GIOFunc)ipc_hup, ipc);

    /* Atomically update ipc->channel. This is done because on the web extension
     * thread, logging spawns a message send thread, which may attempt to write
     * to the uninitialized channel after it has been created with
     * g_io_channel_unix_new(), but before it has been set up fully */
    g_atomic_pointer_set(&ipc->channel, channel);

    ipc->status = IPC_ENDPOINT_CONNECTED;

    if (!endpoints)
        endpoints = g_ptr_array_sized_new(1);

    /* Add the endpoint; it should never be present already */
    g_assert(!g_ptr_array_remove_fast(endpoints, ipc));
    g_ptr_array_add(endpoints, ipc);
}
Пример #20
0
const GPtrArray *
ipc_endpoints_get(void)
{
    if (!endpoints)
        endpoints = g_ptr_array_sized_new(1);
    return endpoints;
}
Пример #21
0
static GPtrArray * 
_hash_table_get_vals (GHashTable *hash_table)
{
    GPtrArray *vals = g_ptr_array_sized_new(g_hash_table_size(hash_table));
    g_hash_table_foreach (hash_table, get_all_vals_helper, vals);
    return vals;
}
Пример #22
0
/**
 * nm_ip4_config_get_domains:
 * @config: a #NMIP4Config
 *
 * Gets the domain names.
 *
 * Returns: (element-type utf8): the #GPtrArray containing domains as strings. This is the 
 * internal copy used by the configuration, and must not be modified.
 **/
const GPtrArray *
nm_ip4_config_get_domains (NMIP4Config *config)
{
	NMIP4ConfigPrivate *priv;
	GValue value = {0,};

	g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);

	priv = NM_IP4_CONFIG_GET_PRIVATE (config);
	if (priv->domains)
		return handle_ptr_array_return (priv->domains);

	if (_nm_object_get_property (NM_OBJECT (config),
	                             NM_DBUS_INTERFACE_IP4_CONFIG,
	                             "Domains",
	                             &value,
	                             NULL)) {
		char **array = NULL, **p;

		array = (char **) g_value_get_boxed (&value);
		if (array && g_strv_length (array)) {
			priv->domains = g_ptr_array_sized_new (g_strv_length (array));
			for (p = array; *p; p++)
				g_ptr_array_add (priv->domains, g_strdup (*p));
		}
		g_value_unset (&value);
	}

	return handle_ptr_array_return (priv->domains);
}
Пример #23
0
loglinesType *
testcase_get_logmessages(gchar *logs)
{
    int i, len;
    loglinesType *self;
    gchar **input_lines;
    gchar *logline;
    GSockAddr *addr = g_sockaddr_inet_new("10.10.10.10", 1010);
    LogMessage *msg;

    self = g_new(loglinesType, 1);
    self->logmessages = g_ptr_array_sized_new(10);
    self->num_of_logs = 0;

    input_lines = g_strsplit(logs, "\n", 0);

    for (i = 0; input_lines[i]; ++i)
    {
        logline = g_strdup_printf("Jul 29 06:25:41 vav zorp/inter_http[27940]: %s", input_lines[i]);
        len = strlen(logline);
        if (logline[len-1] == '\n')
            logline[len-1] = 0;

        msg = log_msg_new(logline, len, addr, &parse_options);
        g_ptr_array_add(self->logmessages, msg);
        ++(self->num_of_logs);
        g_free(logline);
    }

    msg_format_options_destroy(&parse_options);

    return self;
}
Пример #24
0
void setupActiveRepos(activeReposFixture *fixture, gconstpointer testData) {
    (void)testData;
    fixture->hookData = NULL;
    fixture->dnfContext = dnf_context_new();
    int max_size = 3;
    fixture->repoAndProductIds = g_ptr_array_sized_new(max_size);
    fixture->repoProductId1 = initRepoProductId();
    fixture->repoProductId1->repo = dnf_repo_new(fixture->dnfContext);
    dnf_repo_set_enabled(fixture->repoProductId1->repo, TRUE);
    fixture->repoProductId2 = initRepoProductId();
    fixture->repoProductId2->repo = dnf_repo_new(fixture->dnfContext);
    dnf_repo_set_enabled(fixture->repoProductId2->repo, TRUE);
    fixture->repoProductId3 = initRepoProductId();
    fixture->repoProductId3->repo = dnf_repo_new(fixture->dnfContext);
    fixture->activeRepoAndProductIds = g_ptr_array_sized_new(max_size);
}
Пример #25
0
processor_t
proc_new_with_func(sync_data_t sync_data, void (*func)(processor_t))
{
  processor_t proc = (processor_t) malloc(sizeof(struct processor));

  #ifdef DISABLE_QOQ
  proc->qoq = spsc_new(2048);
  proc->qoq_mutex = task_mutex_new();
  #else
  proc->qoq = qoq_new();
  #endif

  stask_init(&proc->stask, sync_data, true);

  proc->available = true;
  proc->mutex = task_mutex_new();
  proc->cv = task_condition_new();


  proc->processing_wait = false;

  proc->privq_cache = g_hash_table_new(NULL, NULL);

  proc->reservation_list = g_ptr_array_sized_new (8);
  pthread_spin_init (&proc->spinlock, PTHREAD_PROCESS_PRIVATE);

  stask_set_func(&proc->stask, (void (*)(void*))func, proc);

  sync_data_enqueue_runnable(sync_data, &proc->stask);

  return proc;
}
void
register_command (GType command_type)
{
	if (Registered_Commands == NULL)
		Registered_Commands = g_ptr_array_sized_new (5);
	g_ptr_array_add (Registered_Commands, fr_registered_command_new (command_type));
}
Пример #27
0
void
p2t_sweepcontext_init (P2tSweepContext* THIS, P2tPointPtrArray polyline)
{
  guint i;

  THIS->front_ = NULL;
  THIS->head_ = NULL;
  THIS->tail_ = NULL;

  THIS->af_head_ = NULL;
  THIS->af_middle_ = NULL;
  THIS->af_tail_ = NULL;

  THIS->edge_list = g_ptr_array_new ();
  THIS->triangles_ = g_ptr_array_new ();
  THIS->map_ = NULL;

  p2t_sweepcontext_basin_init (&THIS->basin);
  p2t_sweepcontext_edgeevent_init (&THIS->edge_event);

  THIS->points_ = g_ptr_array_sized_new (polyline->len);
  for (i = 0; i < polyline->len; i++)
    g_ptr_array_add (THIS->points_, point_index (polyline, i));

  p2t_sweepcontext_init_edges (THIS, THIS->points_);
}
static void
tf_call_channel_get_property (GObject    *object,
    guint       property_id,
    GValue     *value,
    GParamSpec *pspec)
{
  TfCallChannel *self = TF_CALL_CHANNEL (object);

  switch (property_id)
    {
    case PROP_FS_CONFERENCES:
      {
        GPtrArray *array = g_ptr_array_sized_new (
            g_hash_table_size (self->fsconferences));

        g_ptr_array_set_free_func (array, gst_object_unref);
        g_hash_table_foreach (self->fsconferences, conf_into_ptr_array, array);
        g_value_take_boxed (value, array);
      }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
/*
 * tp_base_connection_manager_list_protocols:
 *
 * Implements D-Bus method ListProtocols
 * on interface org.freedesktop.Telepathy.ConnectionManager
 */
static void
tp_base_connection_manager_list_protocols (TpSvcConnectionManager *iface,
                                           DBusGMethodInvocation *context)
{
  TpBaseConnectionManager *self = TP_BASE_CONNECTION_MANAGER (iface);
  GPtrArray *protocols;
  GHashTableIter iter;
  gpointer name;

  /* a D-Bus method shouldn't be happening til we're on D-Bus */
  g_assert (self->priv->registered);

  protocols = g_ptr_array_sized_new (
      g_hash_table_size (self->priv->protocols) + 1);

  g_hash_table_iter_init (&iter, self->priv->protocols);

  while (g_hash_table_iter_next (&iter, &name, NULL))
    {
      g_ptr_array_add (protocols, name);
    }

  g_ptr_array_add (protocols, NULL);

  tp_svc_connection_manager_return_from_list_protocols (
      context, (const gchar **) protocols->pdata);
  g_ptr_array_unref (protocols);
}
Пример #30
0
static GsfInput *
blob_dup (GsfInput *input, G_GNUC_UNUSED GError **err)
{
	GsfStructuredBlob const *src = (GsfStructuredBlob *) input;
	GsfStructuredBlob *dst = g_object_new (GSF_STRUCTURED_BLOB_TYPE, NULL);

	if (src->data != NULL)
		dst->data = g_object_ref (src->data);

	if (src->children != NULL) {
		unsigned i;
		gpointer child;

		dst->children = g_ptr_array_sized_new (src->children->len);
		g_ptr_array_set_size  (dst->children, src->children->len);
		for (i = 0; i < src->children->len ; i++) {
			child = g_ptr_array_index (src->children, i);
			g_ptr_array_index (dst->children, i) = child
				? g_object_ref (child)
				: NULL;
		}
	}

	return GSF_INPUT (dst);
}