summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-02-26 11:14:53 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-02-26 11:14:53 +0000
commit21a038269e8e2264b149e50355e6e18ccba1d334 (patch)
tree6e50133395bbfba07de60a23f8da501eeca26c41 /hcid
parent695443f8d5e0da5fbff3b44279a0ed6abafdf3bb (diff)
More glib memory allocation changes
Diffstat (limited to 'hcid')
-rw-r--r--hcid/dbus-adapter.c8
-rw-r--r--hcid/dbus-manager.c1
-rw-r--r--hcid/dbus-security.c14
-rw-r--r--hcid/dbus-test.c6
-rw-r--r--hcid/device.c1
-rw-r--r--hcid/main.c9
-rw-r--r--hcid/security.c1
-rw-r--r--hcid/storage.c1
8 files changed, 11 insertions, 30 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index 34ababa1..81f6bc35 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -2336,7 +2336,7 @@ static DBusHandlerResult adapter_start_periodic(DBusConnection *conn,
return error_failed(conn, msg, bt_error(status));
}
- adapter->pdiscov_requestor = strdup(dbus_message_get_sender(msg));
+ adapter->pdiscov_requestor = g_strdup(dbus_message_get_sender(msg));
if (adapter->pdiscov_resolve_names)
adapter->discov_type = PERIODIC_INQUIRY | RESOLVE_NAME;
@@ -2523,7 +2523,7 @@ static DBusHandlerResult adapter_discover_devices(DBusConnection *conn,
else
adapter->discov_type |= (STD_INQUIRY | RESOLVE_NAME);
- adapter->discov_requestor = strdup(dbus_message_get_sender(msg));
+ adapter->discov_requestor = g_strdup(dbus_message_get_sender(msg));
reply = dbus_message_new_method_return(msg);
@@ -2597,9 +2597,7 @@ static void list_remote_devices_do_append(char *key, char *value, void *data)
return;
}
- address = strdup(key);
- if (!address)
- return;
+ address = g_strdup(key);
param->list = g_slist_append(param->list, address);
}
diff --git a/hcid/dbus-manager.c b/hcid/dbus-manager.c
index b07d3342..d061e85a 100644
--- a/hcid/dbus-manager.c
+++ b/hcid/dbus-manager.c
@@ -28,7 +28,6 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
-#include <malloc.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
diff --git a/hcid/dbus-security.c b/hcid/dbus-security.c
index ee3b96eb..07a9490f 100644
--- a/hcid/dbus-security.c
+++ b/hcid/dbus-security.c
@@ -200,7 +200,7 @@ static struct passkey_agent *passkey_agent_new(struct adapter *adapter, DBusConn
agent->path = g_strdup(path);
if (addr)
- agent->addr = strdup(addr);
+ agent->addr = g_strdup(addr);
agent->conn = dbus_connection_ref(conn);
@@ -1039,9 +1039,7 @@ static int call_passkey_agent(DBusConnection *conn,
bacpy(&req->sba, sba);
bacpy(&req->bda, dba);
req->agent = agent;
- req->path = strdup(path);
- if (!req->path)
- goto failed;
+ req->path = g_strdup(path);
req->call = agent_request(path, dba, agent, FALSE, 0);
if (!req->call)
@@ -1217,12 +1215,8 @@ static int call_confirm_agent(DBusConnection *conn,
bacpy(&req->sba, sba);
bacpy(&req->bda, dba);
req->agent = agent;
- req->path = strdup(path);
- if (!req->path)
- goto failed;
- req->pin = strdup(pin);
- if (!req->pin)
- goto failed;
+ req->path = g_strdup(path);
+ req->pin = g_strdup(pin);
req->call = agent_confirm(path, dba, agent, pin);
if (!req->call)
diff --git a/hcid/dbus-test.c b/hcid/dbus-test.c
index 1794f276..31b1392e 100644
--- a/hcid/dbus-test.c
+++ b/hcid/dbus-test.c
@@ -95,11 +95,7 @@ static struct audit *audit_new(DBusConnection *conn, DBusMessage *msg,
audit = g_new0(struct audit, 1);
- audit->requestor = strdup(requestor);
- if (!audit->requestor) {
- free(audit);
- return NULL;
- }
+ audit->requestor = g_strdup(requestor);
bacpy(&audit->peer, peer);
bacpy(&audit->local, local);
diff --git a/hcid/device.c b/hcid/device.c
index b76abb9f..4d2239ec 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -29,7 +29,6 @@
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <string.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
diff --git a/hcid/main.c b/hcid/main.c
index 01ca2638..be2a72cd 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -62,7 +62,7 @@ static inline void init_device_defaults(struct device_opts *device_opts)
{
memset(device_opts, 0, sizeof(*device_opts));
device_opts->scan = SCAN_PAGE;
- device_opts->name = strdup("BlueZ");
+ device_opts->name = g_strdup("BlueZ");
device_opts->discovto = HCID_DEFAULT_DISCOVERABLE_TIMEOUT;
}
@@ -91,10 +91,7 @@ static void free_device_opts(void)
{
struct device_list *device, *next;
- if (default_device.name) {
- free(default_device.name);
- default_device.name = NULL;
- }
+ g_free(default_device.name);
for (device = device_list; device; device = next) {
g_free(device->ref);
@@ -693,7 +690,7 @@ int main(int argc, char *argv[])
break;
case 'f':
- hcid.config_file = strdup(optarg);
+ hcid.config_file = g_strdup(optarg);
break;
default:
diff --git a/hcid/security.c b/hcid/security.c
index cf46674c..77062dbd 100644
--- a/hcid/security.c
+++ b/hcid/security.c
@@ -33,7 +33,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
-#include <malloc.h>
#include <string.h>
#include <signal.h>
#include <time.h>
diff --git a/hcid/storage.c b/hcid/storage.c
index 957a1675..d99defb4 100644
--- a/hcid/storage.c
+++ b/hcid/storage.c
@@ -31,7 +31,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
-#include <malloc.h>
#include <time.h>
#include <sys/file.h>
#include <sys/stat.h>