aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiyan <jaraidaniel@gmail.com>2016-10-27 16:49:06 +0200
committerAndreas Blaesius <skate4life@gmx.de>2016-10-27 17:06:31 +0200
commitdfe12bc2a86a369d1c3e66b5da901952ffdff43f (patch)
tree4e98365250a7e69b73195e3193b200ab843c1a1d
parent7eeeb6dad26c68b45da063513f461ff209f5244c (diff)
downloaddevice_samsung_espresso3g-dfe12bc2a86a369d1c3e66b5da901952ffdff43f.zip
device_samsung_espresso3g-dfe12bc2a86a369d1c3e66b5da901952ffdff43f.tar.gz
device_samsung_espresso3g-dfe12bc2a86a369d1c3e66b5da901952ffdff43f.tar.bz2
libsecril-shim: create structs on the stack
For some reason, this seems to be more stable. Change-Id: I4a0a8577288e0e585f9d8e3a62ae4a4b0244a0c8
-rw-r--r--rilsrc/libsecril-shim/secril-shim.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/rilsrc/libsecril-shim/secril-shim.c b/rilsrc/libsecril-shim/secril-shim.c
index 5bc2fb2..0322a6e 100644
--- a/rilsrc/libsecril-shim/secril-shim.c
+++ b/rilsrc/libsecril-shim/secril-shim.c
@@ -7,24 +7,22 @@ static const RIL_RadioFunctions *origRilFunctions;
static const struct RIL_Env *rilEnv;
static void onRequestDial(int request, void *data, size_t datalen, RIL_Token t) {
- RIL_Dial *dial = malloc(sizeof(RIL_Dial));
- RIL_UUS_Info *uusInfo = malloc(sizeof(RIL_UUS_Info));
-
- memcpy(dial, data, datalen);
-
- if (dial->uusInfo == NULL) {
- memset(uusInfo, 0, sizeof(RIL_UUS_Info));
- uusInfo->uusType = (RIL_UUS_Type) 0;
- uusInfo->uusDcs = (RIL_UUS_DCS) 0;
- uusInfo->uusData = NULL;
- uusInfo->uusLength = 0;
- dial->uusInfo = uusInfo;
+ RIL_Dial dial;
+ RIL_UUS_Info uusInfo;
+
+ dial.address = ((RIL_Dial *) data)->address;
+ dial.clir = ((RIL_Dial *) data)->clir;
+ dial.uusInfo = ((RIL_Dial *) data)->uusInfo;
+
+ if (dial.uusInfo == NULL) {
+ uusInfo.uusType = (RIL_UUS_Type) 0;
+ uusInfo.uusDcs = (RIL_UUS_DCS) 0;
+ uusInfo.uusData = NULL;
+ uusInfo.uusLength = 0;
+ dial.uusInfo = &uusInfo;
}
- origRilFunctions->onRequest(request, dial, sizeof(RIL_Dial), t);
-
- free(uusInfo);
- free(dial);
+ origRilFunctions->onRequest(request, &dial, sizeof(dial), t);
}
static void onRequestShim(int request, void *data, size_t datalen, RIL_Token t)
@@ -91,23 +89,21 @@ static void onRequestShim(int request, void *data, size_t datalen, RIL_Token t)
static void onCompleteRequestGetSimStatus(RIL_Token t, RIL_Errno e, void *response, size_t responselen) {
/* While at it, upgrade the response to RIL_CardStatus_v6 */
RIL_CardStatus_v5_samsung *p_cur = ((RIL_CardStatus_v5_samsung *) response);
- RIL_CardStatus_v6 *v6response = malloc(sizeof(RIL_CardStatus_v6));
+ RIL_CardStatus_v6 v6response;
- v6response->card_state = p_cur->card_state;
- v6response->universal_pin_state = p_cur->universal_pin_state;
- v6response->gsm_umts_subscription_app_index = p_cur->gsm_umts_subscription_app_index;
- v6response->cdma_subscription_app_index = p_cur->cdma_subscription_app_index;
- v6response->ims_subscription_app_index = -1;
- v6response->num_applications = p_cur->num_applications;
+ v6response.card_state = p_cur->card_state;
+ v6response.universal_pin_state = p_cur->universal_pin_state;
+ v6response.gsm_umts_subscription_app_index = p_cur->gsm_umts_subscription_app_index;
+ v6response.cdma_subscription_app_index = p_cur->cdma_subscription_app_index;
+ v6response.ims_subscription_app_index = -1;
+ v6response.num_applications = p_cur->num_applications;
int i;
for (i = 0; i < RIL_CARD_MAX_APPS; ++i)
- memcpy(&v6response->applications[i], &p_cur->applications[i], sizeof(RIL_AppStatus));
+ memcpy(&v6response.applications[i], &p_cur->applications[i], sizeof(RIL_AppStatus));
/* Send the fixed response to libril */
- rilEnv->OnRequestComplete(t, e, v6response, sizeof(RIL_CardStatus_v6));
-
- free(v6response);
+ rilEnv->OnRequestComplete(t, e, &v6response, sizeof(RIL_CardStatus_v6));
}
static void fixupDataCallList(void *response, size_t responselen) {