summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdhcp/client.c13
-rw-r--r--gdhcp/gdhcp.h2
2 files changed, 13 insertions, 2 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 7be3d3d7..2e9fe6f0 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -1204,13 +1204,21 @@ GDHCPClientError g_dhcp_client_set_send(GDHCPClient *dhcp_client,
return G_DHCP_CLIENT_ERROR_NONE;
}
-void g_dhcp_client_ref(GDHCPClient *dhcp_client)
+GDHCPClient *g_dhcp_client_ref(GDHCPClient *dhcp_client)
{
+ if (dhcp_client == NULL)
+ return NULL;
+
g_atomic_int_inc(&dhcp_client->ref_count);
+
+ return dhcp_client;
}
void g_dhcp_client_unref(GDHCPClient *dhcp_client)
{
+ if (dhcp_client == NULL)
+ return;
+
if (g_atomic_int_dec_and_test(&dhcp_client->ref_count) == FALSE)
return;
@@ -1231,6 +1239,9 @@ void g_dhcp_client_unref(GDHCPClient *dhcp_client)
void g_dhcp_client_set_debug(GDHCPClient *dhcp_client,
GDHCPDebugFunc func, gpointer data)
{
+ if (dhcp_client == NULL)
+ return;
+
dhcp_client->debug_func = func;
dhcp_client->debug_data = data;
}
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index b18300fc..6111ecb7 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -71,7 +71,7 @@ GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
int g_dhcp_client_start(GDHCPClient *client);
void g_dhcp_client_stop(GDHCPClient *client);
-void g_dhcp_client_ref(GDHCPClient *client);
+GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
void g_dhcp_client_unref(GDHCPClient *client);
void g_dhcp_client_register_event(GDHCPClient *client,