diff options
author | Stefan Schmidt <s.schmidt@samsung.com> | 2014-11-11 11:46:14 +0100 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2014-11-11 11:46:14 +0100 |
commit | 510773a99df919d557323da057034a4cbca1a3f5 (patch) | |
tree | 716715e858f197d2f11a90ed7c1c6b29d3b86c90 /src/lib/elocation/elocation.c | |
parent | 699e5a2bed8e86a966e5872527af9b04d4f5acfe (diff) |
elocation: Cleanup status code handling
The code is an integer enum so we should really handle it like this. Use dummy
free callbacks for ecore_event_add as we pass not malloced data in.
Diffstat (limited to '')
-rw-r--r-- | src/lib/elocation/elocation.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/lib/elocation/elocation.c b/src/lib/elocation/elocation.c index 31065dc0ef..2b795261f4 100644 --- a/src/lib/elocation/elocation.c +++ b/src/lib/elocation/elocation.c | |||
@@ -34,7 +34,7 @@ static Elocation_Position *position = NULL; | |||
34 | static Elocation_Address *addr_geocode = NULL; | 34 | static Elocation_Address *addr_geocode = NULL; |
35 | static Elocation_Position *pos_geocode = NULL; | 35 | static Elocation_Position *pos_geocode = NULL; |
36 | static Elocation_Velocity *velocity = NULL; | 36 | static Elocation_Velocity *velocity = NULL; |
37 | static int *status = -1; /* 0 is a valid status code */ | 37 | static int status = -1; /* 0 is a valid status code */ |
38 | static char nmea_sentence[256]; | 38 | static char nmea_sentence[256]; |
39 | 39 | ||
40 | int _elocation_log_dom = -1; | 40 | int _elocation_log_dom = -1; |
@@ -740,35 +740,29 @@ status_cb(void *data EINA_UNUSED, const Eldbus_Message *reply, Eldbus_Pending *p | |||
740 | return; | 740 | return; |
741 | } | 741 | } |
742 | 742 | ||
743 | /* We need this to be malloced to be passed to ecore_event_add. Or provide a dummy free callback. */ | 743 | if (!eldbus_message_arguments_get(reply,"i", &status)) |
744 | status = malloc(sizeof(*status)); | ||
745 | |||
746 | if (!eldbus_message_arguments_get(reply,"i", status)) | ||
747 | { | 744 | { |
748 | ERR("Error: Unable to unmarshall status"); | 745 | ERR("Error: Unable to unmarshall status"); |
749 | return; | 746 | return; |
750 | } | 747 | } |
751 | 748 | ||
752 | address_provider->status = position_provider->status = *status; | 749 | address_provider->status = position_provider->status = status; |
753 | /* Send out an event to all interested parties that we have an update */ | 750 | /* Send out an event to all interested parties that we have an update */ |
754 | ecore_event_add(ELOCATION_EVENT_STATUS, status, NULL, NULL); | 751 | ecore_event_add(ELOCATION_EVENT_STATUS, &status, _dummy_free, NULL); |
755 | } | 752 | } |
756 | 753 | ||
757 | static void | 754 | static void |
758 | status_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply) | 755 | status_signal_cb(void *data EINA_UNUSED, const Eldbus_Message *reply) |
759 | { | 756 | { |
760 | /* We need this to be malloced to be passed to ecore_event_add. Or provide a dummy free callback. */ | 757 | if (!eldbus_message_arguments_get(reply,"i", &status)) |
761 | status = malloc(sizeof(*status)); | ||
762 | |||
763 | if (!eldbus_message_arguments_get(reply,"i", status)) | ||
764 | { | 758 | { |
765 | ERR("Error: Unable to unmarshall status"); | 759 | ERR("Error: Unable to unmarshall status"); |
766 | return; | 760 | return; |
767 | } | 761 | } |
768 | 762 | ||
769 | address_provider->status = position_provider->status = *status; | 763 | address_provider->status = position_provider->status = status; |
770 | /* Send out an event to all interested parties that we have an update */ | 764 | /* Send out an event to all interested parties that we have an update */ |
771 | ecore_event_add(ELOCATION_EVENT_STATUS, status, NULL, NULL); | 765 | ecore_event_add(ELOCATION_EVENT_STATUS, &status, _dummy_free, NULL); |
772 | } | 766 | } |
773 | 767 | ||
774 | static void | 768 | static void |
@@ -1133,7 +1127,7 @@ elocation_status_get(int *status_shadow) | |||
1133 | { | 1127 | { |
1134 | if (status < 0) return EINA_FALSE; | 1128 | if (status < 0) return EINA_FALSE; |
1135 | 1129 | ||
1136 | status_shadow = status; | 1130 | status_shadow = &status; |
1137 | return EINA_TRUE; | 1131 | return EINA_TRUE; |
1138 | } | 1132 | } |
1139 | 1133 | ||