diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2012-10-31 10:33:32 +0100 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-11-05 14:44:36 +0200 |
commit | 9b1a20b1cf7fcfb080c353120bfc796fda56bf8a (patch) | |
tree | 0888220882942faf7d8936f239510da896450383 | |
parent | 571da6449e813c3cf1a3f9515818d69bbc2e264d (diff) | |
download | connman-9b1a20b1cf7fcfb080c353120bfc796fda56bf8a.tar.gz connman-9b1a20b1cf7fcfb080c353120bfc796fda56bf8a.tar.bz2 connman-9b1a20b1cf7fcfb080c353120bfc796fda56bf8a.zip |
session: Remove name variable from connman_session_bearer
The string is only used when appending the bearer to the D-Bus
message in append_allowed_bearers(). Let's use
__connman_session_type2string() in append_allowed_bearers(). This
saves a bit of memory.
-rw-r--r-- | include/session.h | 1 | ||||
-rw-r--r-- | src/session.c | 15 |
2 files changed, 8 insertions, 8 deletions
diff --git a/include/session.h b/include/session.h index f006e009..73f951d6 100644 --- a/include/session.h +++ b/include/session.h @@ -52,7 +52,6 @@ enum connman_session_type { struct connman_session; struct connman_session_bearer { - char *name; connman_bool_t match_all; enum connman_service_type service_type; }; diff --git a/src/session.c b/src/session.c index 247ff066..d7f015ad 100644 --- a/src/session.c +++ b/src/session.c @@ -377,7 +377,6 @@ static void cleanup_bearer(gpointer data) { struct connman_session_bearer *bearer = data; - g_free(bearer->name); g_free(bearer); } @@ -407,11 +406,10 @@ static int session_parse_allowed_bearers(DBusMessageIter *iter, GSList **list) return -ENOMEM; } - bearer->name = g_strdup(bearer_name); - bearer->service_type = bearer2service(bearer->name); + bearer->service_type = bearer2service(bearer_name); if (bearer->service_type == CONNMAN_SERVICE_TYPE_UNKNOWN && - g_strcmp0(bearer->name, "*") == 0) { + g_strcmp0(bearer_name, "*") == 0) { bearer->match_all = TRUE; } else { bearer->match_all = FALSE; @@ -434,7 +432,6 @@ static struct connman_session_bearer *clone_bearer( if (bearer == NULL) return NULL; - bearer->name = g_strdup(orig->name); bearer->match_all = orig->match_all; bearer->service_type = orig->service_type; @@ -518,7 +515,6 @@ GSList *connman_session_allowed_bearers_any(void) if (bearer == NULL) return NULL; - bearer->name = g_strdup(""); bearer->match_all = TRUE; bearer->service_type = CONNMAN_SERVICE_TYPE_UNKNOWN; @@ -535,9 +531,14 @@ static void append_allowed_bearers(DBusMessageIter *iter, void *user_data) for (list = info->config.allowed_bearers; list != NULL; list = list->next) { struct connman_session_bearer *bearer = list->data; + const char *name = + __connman_service_type2string(bearer->service_type); + + if (name == NULL) + name = "*"; dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, - &bearer->name); + &name); } } |