summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlok Barsode <alok.barsode@azingo.com>2008-07-23 13:42:28 +0530
committerLuiz Augusto von Dentz <luiz.dentz@indt.org.br>2008-07-29 10:49:49 -0300
commit149d5994868e05c44d8e1dfd0547a126e6c48e11 (patch)
tree39df1ac5e502be544ecf7a8339a91c3677214c54
parent5785e005b77ff5f0620dad237aefed0ec087a8f1 (diff)
Adding adapter_free.
Signed-off-by: Alok Barsode <alok.barsode@azingo.com>
-rw-r--r--hcid/adapter.c11
-rw-r--r--hcid/adapter.h1
-rw-r--r--hcid/manager.c5
3 files changed, 14 insertions, 3 deletions
diff --git a/hcid/adapter.c b/hcid/adapter.c
index b82623d6..d5bed46c 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -2581,3 +2581,14 @@ const gchar *adapter_get_address(struct adapter *adapter)
return adapter->address;
}
+
+void adapter_free(struct adapter *adapter)
+{
+ if (!adapter)
+ return;
+
+ g_free(adapter->path);
+ g_free(adapter);
+
+ return;
+}
diff --git a/hcid/adapter.h b/hcid/adapter.h
index e83d808f..d27f85ef 100644
--- a/hcid/adapter.h
+++ b/hcid/adapter.h
@@ -178,3 +178,4 @@ struct adapter *adapter_create(int id);
uint16_t adapter_get_dev_id(struct adapter *adapter);
const gchar *adapter_get_path(struct adapter *adapter);
const gchar *adapter_get_address(struct adapter *adapter);
+void adapter_free(struct adapter *adapter);
diff --git a/hcid/manager.c b/hcid/manager.c
index 03b19848..4f638566 100644
--- a/hcid/manager.c
+++ b/hcid/manager.c
@@ -452,7 +452,7 @@ int manager_register_adapter(int id)
if (!adapter_init(connection, path, adapter)) {
error("Adapter interface init failed on path %s", path);
- g_free(adapter);
+ adapter_free(adapter);
return -1;
}
@@ -488,8 +488,7 @@ int manager_unregister_adapter(int id)
return -1;
}
- g_free(path);
- g_free(adapter);
+ adapter_free(adapter);
return 0;
}