Commit 9f1a60db authored by Mikael Hallendal's avatar Mikael Hallendal

2003-11-26 Mikael Hallendal <micke@imendio.com>

	* bus/*.[ch]:
	* dbus/*.[ch]:
	* glib/*.[ch]: Made ref functions return the pointer
parent 6d9f72b9
2003-11-26 Mikael Hallendal <micke@imendio.com>
* bus/*.[ch]:
* dbus/*.[ch]:
* glib/*.[ch]: Made ref functions return the pointer
2003-11-25 Zack Rusin <zack@kde.org>
* qt/integrator.h, qt/integrator.cpp: Adding handling of DBusServer,
......
......@@ -99,11 +99,13 @@ handle_timeout_callback (DBusTimeout *timeout,
_dbus_wait_for_memory ();
}
static void
static BusPendingActivation *
bus_pending_activation_ref (BusPendingActivation *pending_activation)
{
_dbus_assert (pending_activation->refcount > 0);
pending_activation->refcount += 1;
return pending_activation;
}
static void
......@@ -445,12 +447,14 @@ bus_activation_new (BusContext *context,
return NULL;
}
void
BusActivation *
bus_activation_ref (BusActivation *activation)
{
_dbus_assert (activation->refcount > 0);
activation->refcount += 1;
return activation;
}
void
......
......@@ -32,7 +32,7 @@ BusActivation* bus_activation_new (BusContext *context,
const DBusString *address,
DBusList **directories,
DBusError *error);
void bus_activation_ref (BusActivation *activation);
BusActivation* bus_activation_ref (BusActivation *activation);
void bus_activation_unref (BusActivation *activation);
dbus_bool_t bus_activation_activate_service (BusActivation *activation,
DBusConnection *connection,
......
......@@ -670,11 +670,13 @@ bus_context_shutdown (BusContext *context)
}
}
void
BusContext *
bus_context_ref (BusContext *context)
{
_dbus_assert (context->refcount > 0);
context->refcount += 1;
return context;
}
void
......
......@@ -66,7 +66,7 @@ BusContext* bus_context_new (const DBusStri
int print_pid_fd,
DBusError *error);
void bus_context_shutdown (BusContext *context);
void bus_context_ref (BusContext *context);
BusContext* bus_context_ref (BusContext *context);
void bus_context_unref (BusContext *context);
const char* bus_context_get_type (BusContext *context);
const char* bus_context_get_address (BusContext *context);
......
......@@ -345,12 +345,14 @@ bus_config_parser_new (const DBusString *basedir,
return parser;
}
void
BusConfigParser *
bus_config_parser_ref (BusConfigParser *parser)
{
_dbus_assert (parser->refcount > 0);
parser->refcount += 1;
return parser;
}
void
......
......@@ -37,7 +37,7 @@ typedef struct BusConfigParser BusConfigParser;
BusConfigParser* bus_config_parser_new (const DBusString *basedir,
dbus_bool_t is_toplevel);
void bus_config_parser_ref (BusConfigParser *parser);
BusConfigParser* bus_config_parser_ref (BusConfigParser *parser);
void bus_config_parser_unref (BusConfigParser *parser);
dbus_bool_t bus_config_parser_check_doctype (BusConfigParser *parser,
const char *doctype,
......
......@@ -471,11 +471,13 @@ bus_connections_new (BusContext *context)
return NULL;
}
void
BusConnections *
bus_connections_ref (BusConnections *connections)
{
_dbus_assert (connections->refcount > 0);
connections->refcount += 1;
return connections;
}
void
......
......@@ -33,7 +33,7 @@ typedef dbus_bool_t (* BusConnectionForeachFunction) (DBusConnection *connection
BusConnections* bus_connections_new (BusContext *context);
void bus_connections_ref (BusConnections *connections);
BusConnections* bus_connections_ref (BusConnections *connections);
void bus_connections_unref (BusConnections *connections);
dbus_bool_t bus_connections_setup_connection (BusConnections *connections,
DBusConnection *connection);
......
......@@ -68,12 +68,14 @@ bus_policy_rule_new (BusPolicyRuleType type,
return rule;
}
void
BusPolicyRule *
bus_policy_rule_ref (BusPolicyRule *rule)
{
_dbus_assert (rule->refcount > 0);
rule->refcount += 1;
return rule;
}
void
......@@ -178,12 +180,14 @@ bus_policy_new (void)
return NULL;
}
void
BusPolicy *
bus_policy_ref (BusPolicy *policy)
{
_dbus_assert (policy->refcount > 0);
policy->refcount += 1;
return policy;
}
void
......@@ -628,12 +632,14 @@ bus_client_policy_new (void)
return policy;
}
void
BusClientPolicy *
bus_client_policy_ref (BusClientPolicy *policy)
{
_dbus_assert (policy->refcount > 0);
policy->refcount += 1;
return policy;
}
static void
......
......@@ -101,11 +101,11 @@ struct BusPolicyRule
BusPolicyRule* bus_policy_rule_new (BusPolicyRuleType type,
dbus_bool_t allow);
void bus_policy_rule_ref (BusPolicyRule *rule);
BusPolicyRule* bus_policy_rule_ref (BusPolicyRule *rule);
void bus_policy_rule_unref (BusPolicyRule *rule);
BusPolicy* bus_policy_new (void);
void bus_policy_ref (BusPolicy *policy);
BusPolicy* bus_policy_ref (BusPolicy *policy);
void bus_policy_unref (BusPolicy *policy);
BusClientPolicy* bus_policy_create_client_policy (BusPolicy *policy,
DBusConnection *connection,
......@@ -127,7 +127,7 @@ dbus_bool_t bus_policy_merge (BusPolicy *policy,
BusPolicy *to_absorb);
BusClientPolicy* bus_client_policy_new (void);
void bus_client_policy_ref (BusClientPolicy *policy);
BusClientPolicy* bus_client_policy_ref (BusClientPolicy *policy);
void bus_client_policy_unref (BusClientPolicy *policy);
dbus_bool_t bus_client_policy_check_can_send (BusClientPolicy *policy,
BusRegistry *registry,
......
......@@ -82,11 +82,13 @@ bus_registry_new (BusContext *context)
return NULL;
}
void
BusRegistry *
bus_registry_ref (BusRegistry *registry)
{
_dbus_assert (registry->refcount > 0);
registry->refcount += 1;
return registry;
}
void
......@@ -713,12 +715,14 @@ bus_service_remove_owner (BusService *service,
return TRUE;
}
void
BusService *
bus_service_ref (BusService *service)
{
_dbus_assert (service->refcount > 0);
service->refcount += 1;
return service;
}
void
......
......@@ -33,7 +33,7 @@ typedef void (* BusServiceForeachFunction) (BusService *service,
void *data);
BusRegistry* bus_registry_new (BusContext *context);
void bus_registry_ref (BusRegistry *registry);
BusRegistry* bus_registry_ref (BusRegistry *registry);
void bus_registry_unref (BusRegistry *registry);
BusService* bus_registry_lookup (BusRegistry *registry,
const DBusString *service_name);
......@@ -56,7 +56,7 @@ dbus_bool_t bus_registry_acquire_service (BusRegistry *registry
BusTransaction *transaction,
DBusError *error);
void bus_service_ref (BusService *service);
BusService* bus_service_ref (BusService *service);
void bus_service_unref (BusService *service);
dbus_bool_t bus_service_add_owner (BusService *service,
DBusConnection *owner,
......
......@@ -59,12 +59,14 @@ bus_match_rule_new (DBusConnection *matches_go_to)
return rule;
}
void
BusMatchRule *
bus_match_rule_ref (BusMatchRule *rule)
{
_dbus_assert (rule->refcount > 0);
rule->refcount += 1;
return rule;
}
void
......@@ -765,12 +767,14 @@ bus_matchmaker_new (void)
return matchmaker;
}
void
BusMatchmaker *
bus_matchmaker_ref (BusMatchmaker *matchmaker)
{
_dbus_assert (matchmaker->refcount > 0);
matchmaker->refcount += 1;
return matchmaker;
}
void
......
......@@ -40,7 +40,7 @@ typedef enum
} BusMatchFlags;
BusMatchRule* bus_match_rule_new (DBusConnection *matches_go_to);
void bus_match_rule_ref (BusMatchRule *rule);
BusMatchRule* bus_match_rule_ref (BusMatchRule *rule);
void bus_match_rule_unref (BusMatchRule *rule);
dbus_bool_t bus_match_rule_set_message_type (BusMatchRule *rule,
......@@ -61,7 +61,7 @@ BusMatchRule* bus_match_rule_parse (DBusConnection *matches_go_to,
DBusError *error);
BusMatchmaker* bus_matchmaker_new (void);
void bus_matchmaker_ref (BusMatchmaker *matchmaker);
BusMatchmaker* bus_matchmaker_ref (BusMatchmaker *matchmaker);
void bus_matchmaker_unref (BusMatchmaker *matchmaker);
dbus_bool_t bus_matchmaker_add_rule (BusMatchmaker *matchmaker,
......
......@@ -1894,13 +1894,16 @@ _dbus_auth_client_new (void)
* Increments the refcount of an auth object.
*
* @param auth the auth conversation
* @returns the auth conversation
*/
void
DBusAuth *
_dbus_auth_ref (DBusAuth *auth)
{
_dbus_assert (auth != NULL);
auth->refcount += 1;
return auth;
}
/**
......
......@@ -44,7 +44,7 @@ typedef enum
DBusAuth* _dbus_auth_server_new (void);
DBusAuth* _dbus_auth_client_new (void);
void _dbus_auth_ref (DBusAuth *auth);
DBusAuth* _dbus_auth_ref (DBusAuth *auth);
void _dbus_auth_unref (DBusAuth *auth);
dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth,
const char **mechanisms);
......
......@@ -46,7 +46,7 @@ typedef enum
void _dbus_connection_lock (DBusConnection *connection);
void _dbus_connection_unlock (DBusConnection *connection);
void _dbus_connection_ref_unlocked (DBusConnection *connection);
DBusConnection * _dbus_connection_ref_unlocked (DBusConnection *connection);
void _dbus_connection_unref_unlocked (DBusConnection *connection);
dbus_bool_t _dbus_connection_queue_received_message (DBusConnection *connection,
DBusMessage *message);
......
......@@ -219,11 +219,13 @@ static void _dbus_connection_update_dispatch_status_and_unlock (DB
DBusDispatchStatus new_status);
static void _dbus_connection_last_unref (DBusConnection *connection);
static void
static DBusMessageFilter *
_dbus_message_filter_ref (DBusMessageFilter *filter)
{
_dbus_assert (filter->refcount.value > 0);
_dbus_atomic_inc (&filter->refcount);
return filter;
}
static void
......@@ -963,8 +965,9 @@ _dbus_connection_new_for_transport (DBusTransport *transport)
* Requires that the caller already holds the connection lock.
*
* @param connection the connection.
* @returns the connection.
*/
void
DBusConnection *
_dbus_connection_ref_unlocked (DBusConnection *connection)
{
#ifdef DBUS_HAVE_ATOMIC_INT
......@@ -973,6 +976,8 @@ _dbus_connection_ref_unlocked (DBusConnection *connection)
_dbus_assert (connection->refcount.value > 0);
connection->refcount.value += 1;
#endif
return connection;
}
/**
......@@ -1117,11 +1122,12 @@ dbus_connection_open (const char *address,
* Increments the reference count of a DBusConnection.
*
* @param connection the connection.
* @returns the connection.
*/
void
DBusConnection *
dbus_connection_ref (DBusConnection *connection)
{
_dbus_return_if_fail (connection != NULL);
_dbus_return_val_if_fail (connection != NULL, NULL);
/* The connection lock is better than the global
* lock in the atomic increment fallback
......@@ -1136,6 +1142,8 @@ dbus_connection_ref (DBusConnection *connection)
connection->refcount.value += 1;
CONNECTION_UNLOCK (connection);
#endif
return connection;
}
static void
......
......@@ -95,7 +95,7 @@ typedef DBusHandlerResult (* DBusHandleMessageFunction) (DBusConnection *con
DBusConnection* dbus_connection_open (const char *address,
DBusError *error);
void dbus_connection_ref (DBusConnection *connection);
DBusConnection* dbus_connection_ref (DBusConnection *connection);
void dbus_connection_unref (DBusConnection *connection);
void dbus_connection_disconnect (DBusConnection *connection);
dbus_bool_t dbus_connection_get_is_connected (DBusConnection *connection);
......
......@@ -348,11 +348,14 @@ _dbus_hash_table_new (DBusHashType type,
* Increments the reference count for a hash table.
*
* @param table the hash table to add a reference to.
* @returns the hash table.
*/
void
DBusHashTable *
_dbus_hash_table_ref (DBusHashTable *table)
{
table->refcount += 1;
return table;
}
/**
......
......@@ -61,7 +61,7 @@ typedef enum
DBusHashTable* _dbus_hash_table_new (DBusHashType type,
DBusFreeFunction key_free_function,
DBusFreeFunction value_free_function);
void _dbus_hash_table_ref (DBusHashTable *table);
DBusHashTable* _dbus_hash_table_ref (DBusHashTable *table);
void _dbus_hash_table_unref (DBusHashTable *table);
void _dbus_hash_iter_init (DBusHashTable *table,
DBusHashIter *iter);
......
......@@ -657,11 +657,14 @@ _dbus_keyring_reload (DBusKeyring *keyring,
* Increments reference count of the keyring
*
* @param keyring the keyring
* @returns the keyring
*/
void
DBusKeyring *
_dbus_keyring_ref (DBusKeyring *keyring)
{
keyring->refcount += 1;
return keyring;
}
/**
......
......@@ -34,7 +34,7 @@ typedef struct DBusKeyring DBusKeyring;
DBusKeyring* _dbus_keyring_new_homedir (const DBusString *username,
const DBusString *context,
DBusError *error);
void _dbus_keyring_ref (DBusKeyring *keyring);
DBusKeyring* _dbus_keyring_ref (DBusKeyring *keyring);
void _dbus_keyring_unref (DBusKeyring *keyring);
dbus_bool_t _dbus_keyring_validate_context (const DBusString *context);
int _dbus_keyring_get_best_key (DBusKeyring *keyring,
......
......@@ -123,12 +123,14 @@ timeout_callback_new (DBusTimeout *timeout,
return cb;
}
static void
static Callback *
callback_ref (Callback *cb)
{
_dbus_assert (cb->refcount > 0);
cb->refcount += 1;
return cb;
}
static void
......@@ -204,13 +206,15 @@ _dbus_loop_new (void)
return loop;
}
void
DBusLoop *
_dbus_loop_ref (DBusLoop *loop)
{
_dbus_assert (loop != NULL);
_dbus_assert (loop->refcount > 0);
loop->refcount += 1;
return loop;
}
void
......
......@@ -37,7 +37,7 @@ typedef void (* DBusTimeoutFunction) (DBusTimeout *timeout,
void *data);
DBusLoop* _dbus_loop_new (void);
void _dbus_loop_ref (DBusLoop *loop);
DBusLoop* _dbus_loop_ref (DBusLoop *loop);
void _dbus_loop_unref (DBusLoop *loop);
dbus_bool_t _dbus_loop_add_watch (DBusLoop *loop,
DBusWatch *watch,
......
......@@ -189,13 +189,16 @@ dbus_message_handler_new (DBusHandleMessageFunction function,
* Increments the reference count on a message handler.
*
* @param handler the handler
* @returns the handler
*/
void
DBusMessageHandler *
dbus_message_handler_ref (DBusMessageHandler *handler)
{
_dbus_return_if_fail (handler != NULL);
_dbus_atomic_inc (&handler->refcount);
return handler;
}
/**
......
......@@ -43,7 +43,7 @@ DBusMessageHandler* dbus_message_handler_new (DBusHandleMessageFunction functio
DBusFreeFunction free_user_data);
void dbus_message_handler_ref (DBusMessageHandler *handler);
DBusMessageHandler* dbus_message_handler_ref (DBusMessageHandler *handler);
void dbus_message_handler_unref (DBusMessageHandler *handler);
......
......@@ -48,7 +48,7 @@ void _dbus_message_remove_size_counter (DBusMessage *message,
DBusList **link_return);
DBusMessageLoader* _dbus_message_loader_new (void);
void _dbus_message_loader_ref (DBusMessageLoader *loader);
DBusMessageLoader* _dbus_message_loader_ref (DBusMessageLoader *loader);
void _dbus_message_loader_unref (DBusMessageLoader *loader);
void _dbus_message_loader_get_buffer (DBusMessageLoader *loader,
......
......@@ -1504,17 +1504,20 @@ dbus_message_copy (const DBusMessage *message)
* Increments the reference count of a DBusMessage.
*
* @param message The message
* @returns the message
* @see dbus_message_unref
*/
void
DBusMessage *
dbus_message_ref (DBusMessage *message)
{
dbus_int32_t old_refcount;
_dbus_return_if_fail (message != NULL);
_dbus_return_val_if_fail (message != NULL, NULL);
old_refcount = _dbus_atomic_inc (&message->refcount);
_dbus_assert (old_refcount >= 1);
return message;
}
static void
......@@ -4781,11 +4784,14 @@ _dbus_message_loader_new (void)
* Increments the reference count of the loader.
*
* @param loader the loader.
* @returns the loader
*/
void
DBusMessageLoader *
_dbus_message_loader_ref (DBusMessageLoader *loader)
{
loader->refcount += 1;
return loader;
}
/**
......
......@@ -73,9 +73,9 @@ DBusMessage* dbus_message_new_error (DBusMessage *reply_to,
const char *error_name,
const char *error_message);
DBusMessage *dbus_message_copy (const DBusMessage *message);
DBusMessage* dbus_message_copy (const DBusMessage *message);
void dbus_message_ref (DBusMessage *message);
DBusMessage* dbus_message_ref (DBusMessage *message);
void dbus_message_unref (DBusMessage *message);
int dbus_message_get_type (DBusMessage *message);
dbus_bool_t dbus_message_set_path (DBusMessage *message,
......
......@@ -46,7 +46,7 @@ typedef struct DBusObjectSubtree DBusObjectSubtree;
static DBusObjectSubtree* _dbus_object_subtree_new (const char *name,
const DBusObjectPathVTable *vtable,
void *user_data);
static void _dbus_object_subtree_ref (DBusObjectSubtree *subtree);
static DBusObjectSubtree* _dbus_object_subtree_ref (DBusObjectSubtree *subtree);
static void _dbus_object_subtree_unref (DBusObjectSubtree *subtree);
/**
......@@ -121,13 +121,16 @@ _dbus_object_tree_new (DBusConnection *connection)
/**
* Increment the reference count
* @param tree the object tree
* @returns the object tree
*/
void
DBusObjectTree *
_dbus_object_tree_ref (DBusObjectTree *tree)
{
_dbus_assert (tree->refcount > 0);
tree->refcount += 1;
return tree;
}
/**
......@@ -859,11 +862,13 @@ _dbus_object_subtree_new (const char *name,
return NULL;
}
static void
static DBusObjectSubtree *
_dbus_object_subtree_ref (DBusObjectSubtree *subtree)
{
_dbus_assert (subtree->refcount.value > 0);
_dbus_atomic_inc (&subtree->refcount);
return subtree;
}
static void
......
......@@ -30,7 +30,7 @@ DBUS_BEGIN_DECLS;
typedef struct DBusObjectTree DBusObjectTree;
DBusObjectTree* _dbus_object_tree_new (DBusConnection *connection);
void _dbus_object_tree_ref (DBusObjectTree *tree);
DBusObjectTree* _dbus_object_tree_ref (DBusObjectTree *tree);
void _dbus_object_tree_unref (DBusObjectTree *tree);
dbus_bool_t _dbus_object_tree_register (DBusObjectTree *tree,
......
......@@ -138,13 +138,16 @@ _dbus_pending_call_notify (DBusPendingCall *pending)
* Increments the reference count on a pending call.
*
* @param pending the pending call object
* @returns the pending call object
*/
void
DBusPendingCall *
dbus_pending_call_ref (DBusPendingCall *pending)
{
_dbus_return_if_fail (pending != NULL);
_dbus_atomic_inc (&pending->refcount);
return pending;
}
/**
......
......@@ -33,7 +33,7 @@
DBUS_BEGIN_DECLS;
void dbus_pending_call_ref (DBusPendingCall *pending);
DBusPendingCall* dbus_pending_call_ref (DBusPendingCall *pending);
void dbus_pending_call_unref (DBusPendingCall *pending);
dbus_bool_t dbus_pending_call_set_notify (DBusPendingCall *pending,
DBusPendingCallNotifyFunction function,
......
......@@ -96,13 +96,16 @@ _dbus_counter_new (void)
* Increments refcount of the counter
*
* @param counter the counter
* @returns the counter
*/
void
DBusCounter *
_dbus_counter_ref (DBusCounter *counter)
{
_dbus_assert (counter->refcount > 0);
counter->refcount += 1;
return counter;
}
/**
......
......@@ -35,7 +35,7 @@ typedef void (* DBusCounterNotifyFunction) (DBusCounter *counter,
void *user_data);
DBusCounter* _dbus_counter_new (void);
void _dbus_counter_ref (DBusCounter *counter);
DBusCounter* _dbus_counter_ref (DBusCounter *counter);
void _dbus_counter_unref (DBusCounter *counter);
void _dbus_counter_adjust (DBusCounter *counter,
long delta);
......
......@@ -450,13 +450,16 @@ dbus_server_listen (const char *address,
* Increments the reference count of a DBusServer.
*
* @param server the server.
* @returns the server
*/
void
DBusServer *
dbus_server_ref (DBusServer *server)
{
_dbus_return_if_fail (server != NULL);
server->refcount += 1;
return server;
}
/**
......
......@@ -41,7 +41,7 @@ typedef void (* DBusNewConnectionFunction) (DBusServer *server,
DBusServer* dbus_server_listen (const char *address,
DBusError *error);
void dbus_server_ref (DBusServer *server);
DBusServer* dbus_server_ref (DBusServer *server);
void dbus_server_unref (DBusServer *server);
void dbus_server_disconnect (DBusServer *server);
dbus_bool_t dbus_server_get_is_connected (DBusServer *server);
......
......@@ -235,14 +235,17 @@ _dbus_babysitter_new (void)
* Increment the reference count on the babysitter object.
*
* @param sitter the babysitter
* @returns the babysitter
*/
void
DBusBabysitter *
_dbus_babysitter_ref (DBusBabysitter *sitter)
{