本文整理汇总了C++中dbus_new0函数的典型用法代码示例。如果您正苦于以下问题:C++ dbus_new0函数的具体用法?C++ dbus_new0怎么用?C++ dbus_new0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbus_new0函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _dbus_socket_set_poll_new
DBusSocketSet *
_dbus_socket_set_poll_new (int size_hint)
{
DBusSocketSetPoll *ret;
if (size_hint <= 0)
size_hint = DEFAULT_SIZE_HINT;
ret = dbus_new0 (DBusSocketSetPoll, 1);
if (ret == NULL)
return NULL;
ret->parent.cls = &_dbus_socket_set_poll_class;
ret->n_fds = 0;
ret->n_allocated = size_hint;
ret->fds = dbus_new0 (DBusPollFD, size_hint);
if (ret->fds == NULL)
{
/* socket_set_poll_free specifically supports half-constructed
* socket sets */
socket_set_poll_free ((DBusSocketSet *) ret);
return NULL;
}
_dbus_verbose ("new socket set at %p\n", ret);
return (DBusSocketSet *) ret;
}
示例2: _dbus_loop_iterate
dbus_bool_t
_dbus_loop_iterate (DBusLoop *loop,
dbus_bool_t block)
{
#define N_STACK_DESCRIPTORS 64
dbus_bool_t retval;
DBusPollFD *fds;
DBusPollFD stack_fds[N_STACK_DESCRIPTORS];
int n_fds;
WatchCallback **watches_for_fds;
WatchCallback *stack_watches_for_fds[N_STACK_DESCRIPTORS];
int i;
DBusList *link;
int n_ready;
int initial_serial;
long timeout;
dbus_bool_t oom_watch_pending;
int orig_depth;
retval = FALSE;
fds = NULL;
watches_for_fds = NULL;
n_fds = 0;
oom_watch_pending = FALSE;
orig_depth = loop->depth;
#if MAINLOOP_SPEW
_dbus_verbose ("Iteration block=%d depth=%d timeout_count=%d watch_count=%d\n",
block, loop->depth, loop->timeout_count, loop->watch_count);
#endif
if (loop->callbacks == NULL)
goto next_iteration;
if (loop->watch_count > N_STACK_DESCRIPTORS)
{
fds = dbus_new0 (DBusPollFD, loop->watch_count);
while (fds == NULL)
{
_dbus_wait_for_memory ();
fds = dbus_new0 (DBusPollFD, loop->watch_count);
}
watches_for_fds = dbus_new (WatchCallback*, loop->watch_count);
while (watches_for_fds == NULL)
{
_dbus_wait_for_memory ();
watches_for_fds = dbus_new (WatchCallback*, loop->watch_count);
}
}
示例3: _dbus_babysitter_new
static DBusBabysitter*
_dbus_babysitter_new (void)
{
DBusBabysitter *sitter;
sitter = dbus_new0 (DBusBabysitter, 1);
if (sitter == NULL)
return NULL;
sitter->refcount = 1;
sitter->socket_to_babysitter.fd = -1;
sitter->error_pipe_from_child = -1;
sitter->sitter_pid = -1;
sitter->grandchild_pid = -1;
sitter->watches = _dbus_watch_list_new ();
if (sitter->watches == NULL)
goto failed;
return sitter;
failed:
_dbus_babysitter_unref (sitter);
return NULL;
}
示例4: _dbus_keyring_new
static DBusKeyring*
_dbus_keyring_new (void)
{
DBusKeyring *keyring;
keyring = dbus_new0 (DBusKeyring, 1);
if (keyring == NULL)
goto out_0;
if (!_dbus_string_init (&keyring->directory))
goto out_1;
if (!_dbus_string_init (&keyring->filename))
goto out_2;
if (!_dbus_string_init (&keyring->filename_lock))
goto out_3;
keyring->refcount = 1;
keyring->keys = NULL;
keyring->n_keys = 0;
return keyring;
out_3:
_dbus_string_free (&keyring->filename);
out_2:
_dbus_string_free (&keyring->directory);
out_1:
dbus_free (keyring);
out_0:
return NULL;
}
示例5: _dbus_watch_new
/**
* Creates a new DBusWatch. Used to add a file descriptor to be polled
* by a main loop.
*
* @param fd the file descriptor to be watched.
* @param flags the conditions to watch for on the descriptor.
* @param enabled the initial enabled state
* @param handler the handler function
* @param data data for handler function
* @param free_data_function function to free the data
* @returns the new DBusWatch object.
*/
DBusWatch*
_dbus_watch_new (int fd,
unsigned int flags,
dbus_bool_t enabled,
DBusWatchHandler handler,
void *data,
DBusFreeFunction free_data_function)
{
DBusWatch *watch;
#define VALID_WATCH_FLAGS (DBUS_WATCH_WRITABLE | DBUS_WATCH_READABLE)
_dbus_assert ((flags & VALID_WATCH_FLAGS) == flags);
watch = dbus_new0 (DBusWatch, 1);
if (watch == NULL)
return NULL;
watch->refcount = 1;
watch->fd = fd;
watch->flags = flags;
watch->enabled = enabled;
watch->handler = handler;
watch->handler_data = data;
watch->free_handler_data_function = free_data_function;
return watch;
}
示例6: _dbus_loop_new
DBusLoop*
_dbus_loop_new (void)
{
DBusLoop *loop;
loop = dbus_new0 (DBusLoop, 1);
if (loop == NULL)
return NULL;
loop->watches = _dbus_hash_table_new (DBUS_HASH_POLLABLE, NULL,
free_watch_table_entry);
loop->socket_set = _dbus_socket_set_new (0);
if (loop->watches == NULL || loop->socket_set == NULL)
{
if (loop->watches != NULL)
_dbus_hash_table_unref (loop->watches);
if (loop->socket_set != NULL)
_dbus_socket_set_free (loop->socket_set);
dbus_free (loop);
return NULL;
}
loop->refcount = 1;
return loop;
}
示例7: _dbus_directory_open
DBusDirIter*
_dbus_directory_open (const DBusString *filename,
DBusError *error)
{
DIR *d;
DBusDirIter *iter;
const char *filename_c;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
filename_c = _dbus_string_get_const_data (filename);
d = opendir (filename_c);
if (d == NULL)
{
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to read directory \"%s\": %s",
filename_c,
_dbus_strerror (errno));
return NULL;
}
iter = dbus_new0 (DBusDirIter, 1);
if (iter == NULL)
{
closedir (d);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Could not allocate memory for directory iterator");
return NULL;
}
iter->d = d;
return iter;
}
示例8: dbus_fake_mutex_new
static DBusMutex *
dbus_fake_mutex_new (void)
{
DBusFakeMutex *mutex;
mutex = dbus_new0 (DBusFakeMutex, 1);
return (DBusMutex *)mutex;
}
示例9: _dbus_pending_call_new_unlocked
/**
* Creates a new pending reply object.
*
* @param connection connection where reply will arrive
* @param timeout_milliseconds length of timeout, -1 (or
* #DBUS_TIMEOUT_USE_DEFAULT) for default,
* #DBUS_TIMEOUT_INFINITE for no timeout
* @param timeout_handler timeout handler, takes pending call as data
* @returns a new #DBusPendingCall or #NULL if no memory.
*/
DBusPendingCall*
_dbus_pending_call_new_unlocked (DBusConnection *connection,
int timeout_milliseconds,
DBusTimeoutHandler timeout_handler)
{
DBusPendingCall *pending;
DBusTimeout *timeout;
_dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
if (timeout_milliseconds == -1)
timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
if (!dbus_pending_call_allocate_data_slot (¬ify_user_data_slot))
return NULL;
pending = dbus_new0 (DBusPendingCall, 1);
if (pending == NULL)
{
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
return NULL;
}
if (timeout_milliseconds != DBUS_TIMEOUT_INFINITE)
{
timeout = _dbus_timeout_new (timeout_milliseconds,
timeout_handler,
pending, NULL);
if (timeout == NULL)
{
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
dbus_free (pending);
return NULL;
}
pending->timeout = timeout;
}
else
{
pending->timeout = NULL;
}
_dbus_atomic_inc (&pending->refcount);
pending->connection = connection;
_dbus_connection_ref_unlocked (pending->connection);
_dbus_data_slot_list_init (&pending->slot_list);
_dbus_pending_call_trace_ref (pending, 0, 1, "new_unlocked");
return pending;
}
示例10: _dbus_timeout_list_new
/**
* Creates a new timeout list. Returns #NULL if insufficient
* memory exists.
*
* @returns the new timeout list, or #NULL on failure.
*/
DBusTimeoutList*
_dbus_timeout_list_new (void)
{
DBusTimeoutList *timeout_list;
timeout_list = dbus_new0 (DBusTimeoutList, 1);
if (timeout_list == NULL)
return NULL;
return timeout_list;
}
示例11: _dbus_pending_call_new_unlocked
/**
* Creates a new pending reply object.
*
* @param connection connection where reply will arrive
* @param timeout_milliseconds length of timeout, -1 for default
* @param timeout_handler timeout handler, takes pending call as data
* @returns a new #DBusPendingCall or #NULL if no memory.
*/
DBusPendingCall*
_dbus_pending_call_new_unlocked (DBusConnection *connection,
int timeout_milliseconds,
DBusTimeoutHandler timeout_handler)
{
DBusPendingCall *pending;
DBusTimeout *timeout;
_dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
if (timeout_milliseconds == -1)
timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
/* it would probably seem logical to pass in _DBUS_INT_MAX for
* infinite timeout, but then math in
* _dbus_connection_block_for_reply would get all overflow-prone, so
* smack that down.
*/
if (timeout_milliseconds > _DBUS_ONE_HOUR_IN_MILLISECONDS * 6)
timeout_milliseconds = _DBUS_ONE_HOUR_IN_MILLISECONDS * 6;
if (!dbus_pending_call_allocate_data_slot (¬ify_user_data_slot))
return NULL;
pending = dbus_new0 (DBusPendingCall, 1);
if (pending == NULL)
{
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
return NULL;
}
timeout = _dbus_timeout_new (timeout_milliseconds,
timeout_handler,
pending, NULL);
if (timeout == NULL)
{
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
dbus_free (pending);
return NULL;
}
pending->refcount.value = 1;
pending->connection = connection;
_dbus_connection_ref_unlocked (pending->connection);
pending->timeout = timeout;
_dbus_data_slot_list_init (&pending->slot_list);
return pending;
}
示例12: _dbus_watch_list_new
/**
* Creates a new watch list. Returns #NULL if insufficient
* memory exists.
*
* @returns the new watch list, or #NULL on failure.
*/
DBusWatchList*
_dbus_watch_list_new (void)
{
DBusWatchList *watch_list;
watch_list = dbus_new0 (DBusWatchList, 1);
if (watch_list == NULL)
return NULL;
return watch_list;
}
示例13: setup_server
static dbus_bool_t
setup_server (BusContext *context,
DBusServer *server,
char **auth_mechanisms,
DBusError *error)
{
BusServerData *bd;
bd = dbus_new0 (BusServerData, 1);
if (bd == NULL || !dbus_server_set_data (server,
server_data_slot,
bd, free_server_data))
{
dbus_free (bd);
BUS_SET_OOM (error);
return FALSE;
}
bd->context = context;
if (!dbus_server_set_auth_mechanisms (server, (const char**) auth_mechanisms))
{
BUS_SET_OOM (error);
return FALSE;
}
dbus_server_set_new_connection_function (server,
new_connection_callback,
context, NULL);
if (!dbus_server_set_watch_functions (server,
add_server_watch,
remove_server_watch,
toggle_server_watch,
server,
NULL))
{
BUS_SET_OOM (error);
return FALSE;
}
if (!dbus_server_set_timeout_functions (server,
add_server_timeout,
remove_server_timeout,
NULL,
server, NULL))
{
BUS_SET_OOM (error);
return FALSE;
}
return TRUE;
}
示例14: _dbus_counter_new
/**
* Creates a new DBusCounter. DBusCounter is used
* to count usage of some resource such as memory.
*
* @returns new counter or #NULL on failure
*/
DBusCounter*
_dbus_counter_new (void)
{
DBusCounter *counter;
counter = dbus_new0 (DBusCounter, 1);
if (counter == NULL)
return NULL;
counter->refcount = 1;
return counter;
}
示例15: _dbus_loop_new
DBusLoop*
_dbus_loop_new (void)
{
DBusLoop *loop;
loop = dbus_new0 (DBusLoop, 1);
if (loop == NULL)
return NULL;
loop->refcount = 1;
return loop;
}