summaryrefslogtreecommitdiff
path: root/utils/loc_log.cpp
diff options
context:
space:
mode:
authorValeri Atamaniouk <valeria@codeaurora.org>2015-10-21 18:53:58 +0300
committerValeri Atamaniouk <valeria@codeaurora.org>2015-11-09 11:33:15 +0200
commit78bb13288e9ac69a985cf8a4b8c15b21770b59c5 (patch)
tree16c9b3b8582db269f758c24b3a44c439539fa7ff /utils/loc_log.cpp
parent15ea4fca381ca7cc2085fae72318a9b0c1cedbed (diff)
downloadgps-78bb13288e9ac69a985cf8a4b8c15b21770b59c5.tar.gz
Location: reduce memory footprint
Reduce memory footprint by moving data sets into const data segments. Update function parameters to accept const parameters when appropriate. CRs-fixed: 928770 Change-Id: I42955cf18de2b0541cfaed89359cdcf9ae6fea8a
Diffstat (limited to 'utils/loc_log.cpp')
-rw-r--r--utils/loc_log.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/utils/loc_log.cpp b/utils/loc_log.cpp
index 5500dea..76f0c53 100644
--- a/utils/loc_log.cpp
+++ b/utils/loc_log.cpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2012, 2015, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -57,9 +57,9 @@ const char EXIT_ERROR_TAG[] = "Exiting with error";
loc_logger_s_type loc_logger;
/* Get names from value */
-const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size, long mask)
+const char* loc_get_name_from_mask(const loc_name_val_s_type table[], size_t table_size, long mask)
{
- int i;
+ size_t i;
for (i = 0; i < table_size; i++)
{
if (table[i].val & (long) mask)
@@ -71,9 +71,9 @@ const char* loc_get_name_from_mask(loc_name_val_s_type table[], int table_size,
}
/* Get names from value */
-const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, long value)
+const char* loc_get_name_from_val(const loc_name_val_s_type table[], size_t table_size, long value)
{
- int i;
+ size_t i;
for (i = 0; i < table_size; i++)
{
if (table[i].val == (long) value)
@@ -84,7 +84,7 @@ const char* loc_get_name_from_val(loc_name_val_s_type table[], int table_size, l
return UNKNOWN_STR;
}
-static loc_name_val_s_type loc_msg_q_status[] =
+static const loc_name_val_s_type loc_msg_q_status[] =
{
NAME_VAL( eMSG_Q_SUCCESS ),
NAME_VAL( eMSG_Q_FAILURE_GENERAL ),
@@ -93,7 +93,7 @@ static loc_name_val_s_type loc_msg_q_status[] =
NAME_VAL( eMSG_Q_UNAVAILABLE_RESOURCE ),
NAME_VAL( eMSG_Q_INSUFFICIENT_BUFFER )
};
-static int loc_msg_q_status_num = sizeof(loc_msg_q_status) / sizeof(loc_name_val_s_type);
+static const size_t loc_msg_q_status_num = LOC_TABLE_SIZE(loc_msg_q_status);
/* Find msg_q status name */
const char* loc_get_msg_q_status(int status)
@@ -107,7 +107,7 @@ const char* log_succ_fail_string(int is_succ)
}
//Target names
-loc_name_val_s_type target_name[] =
+static const loc_name_val_s_type target_name[] =
{
NAME_VAL(GNSS_NONE),
NAME_VAL(GNSS_MSM),
@@ -118,7 +118,7 @@ loc_name_val_s_type target_name[] =
NAME_VAL(GNSS_UNKNOWN)
};
-static int target_name_num = sizeof(target_name)/sizeof(loc_name_val_s_type);
+static const size_t target_name_num = LOC_TABLE_SIZE(target_name);
/*===========================================================================
@@ -139,7 +139,7 @@ const char *loc_get_target_name(unsigned int target)
static char ret[BUFFER_SIZE];
index = getTargetGnssType(target);
- if( index >= target_name_num || index < 0)
+ if( index < 0 || (unsigned)index >= target_name_num )
index = target_name_num - 1;
if( (target & HAS_SSC) == HAS_SSC ) {
@@ -168,7 +168,7 @@ RETURN VALUE
The time string
===========================================================================*/
-char *loc_get_time(char *time_string, unsigned long buf_size)
+char *loc_get_time(char *time_string, size_t buf_size)
{
struct timeval now; /* sec and usec */
struct tm now_tm; /* broken-down time */