diff options
author | Daniel Wagner <daniel.wagner@bmw-carit.de> | 2010-10-13 09:26:46 +0200 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2010-10-13 12:05:15 +0200 |
commit | cb3e527d1f0b58ea2f90c72ec73130fc10e6aa54 (patch) | |
tree | db070ba41967d39d1e245b2a2dd079d0bae7dab6 /src/stats.c | |
parent | bb80336d0e9f53904789a6c47d36d41f7ebe3086 (diff) | |
download | connman-cb3e527d1f0b58ea2f90c72ec73130fc10e6aa54.tar.gz connman-cb3e527d1f0b58ea2f90c72ec73130fc10e6aa54.tar.bz2 connman-cb3e527d1f0b58ea2f90c72ec73130fc10e6aa54.zip |
Merge stats_create into __connman_stats_service_register
This avoid doing an hash table lookup from
__connman_stats_service_register() right after inserting the stats_file
pointer into it.
Diffstat (limited to 'src/stats.c')
-rw-r--r-- | src/stats.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/stats.c b/src/stats.c index 7d05b893..a4fcc9ea 100644 --- a/src/stats.c +++ b/src/stats.c @@ -201,19 +201,6 @@ static void stats_free(gpointer user_data) g_free(file); } -static int stats_create(struct connman_service *service) -{ - struct stats_file *file; - - file = g_try_new0(struct stats_file, 1); - if (file == NULL) - return -ENOMEM; - - g_hash_table_insert(stats_hash, service, file); - - return 0; -} - static void update_first(struct stats_file *file) { file->first = (struct stats_record *) @@ -362,12 +349,11 @@ int __connman_stats_service_register(struct connman_service *service) file = g_hash_table_lookup(stats_hash, service); if (file == NULL) { - err = stats_create(service); - - if (err < 0) - return err; + file = g_try_new0(struct stats_file, 1); + if (file == NULL) + return -ENOMEM; - file = g_hash_table_lookup(stats_hash, service); + g_hash_table_insert(stats_hash, service, file); } else { return -EALREADY; } |