worldclock: fix linking issue with malloc 92/138192/2 submit/tizen/20170717.135244
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 11 Jul 2017 10:48:45 +0000 (12:48 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Mon, 17 Jul 2017 10:17:44 +0000 (10:17 +0000)
The Worldclock was using 'malloc' to construct Edje_Message_Int_Set struct.
This leads to problems on Tizen SDK 4.0 build, when during linking
'malloc' symbol was resolved not from glibc, but from libchromium-ewk.so.

This lead to crash when trying to use chromium's malloc.

Due to way how SDK build system works, I cannot remove libchromium from link options.
Instead I removed all usage of malloc in code.

Additionally add static to internal function

Change-Id: I87d188b959dfdedd175986ac102b46db062964a9

clock/src/View/AlarmView.cpp
clock/src/View/WorldClockView.cpp

index b946a78..f630a58 100644 (file)
@@ -75,7 +75,7 @@ void AlarmView::ItemClicked(void *data, Evas_Object *obj, void *info)
        id->instance->OnItemToggled((uintptr_t)id->it);
 }
 
-void SetItemRepeatIconVisibility(Elm_Object_Item *it, bool visible)
+static void SetItemRepeatIconVisibility(Elm_Object_Item *it, bool visible)
 {
        if (visible) {
                elm_object_item_signal_emit(it, "show,repeat,icon", "clock");
index 8ec5885..f53ae5d 100644 (file)
@@ -573,11 +573,10 @@ Evas_Object *WorldClockView::CreateFloatingButton()
 
 void WorldClockView::UpdateTimezoneLocationsDots(const model::Timezone *timezone)
 {
+       Edje_Message_Int_Set *msg = (Edje_Message_Int_Set *) new char[sizeof(Edje_Message_Int_Set) + 3 * sizeof(int)];
+       msg->count = 4;
+
        for (unsigned int i = 0; i < 8; i++) {
-               Edje_Message_Int_Set *msg;
-               msg = (Edje_Message_Int_Set *) malloc(
-                       sizeof(Edje_Message_Int_Set) + 3 * sizeof(int));
-               msg->count = 4;
 
                if (i >= timezone->places.size()) {
                        msg->val[0] = 100;
@@ -593,8 +592,8 @@ void WorldClockView::UpdateTimezoneLocationsDots(const model::Timezone *timezone
                msg->val[3] = i;
                edje_object_message_send(elm_layout_edje_get(world_clock_map_), EDJE_MESSAGE_INT_SET,
                        MESSAGE_ID_SET_LOCATION_DOT_POSITION, (void *) msg);
-               free(msg);
        }
+       delete[] msg;
 }
 
 void WorldClockView::UpdateGmtOffset(const model::Timezone *timezone)
@@ -605,8 +604,7 @@ void WorldClockView::UpdateGmtOffset(const model::Timezone *timezone)
 
 void WorldClockView::UpdateTimezoneArea(const model::Timezone *timezone)
 {
-       Edje_Message_Int_Set *msg = static_cast<Edje_Message_Int_Set *>
-               (malloc(sizeof(Edje_Message_Int_Set) + sizeof(int)));
+       Edje_Message_Int_Set *msg = (Edje_Message_Int_Set *) new char[sizeof(Edje_Message_Int_Set) + sizeof(int)];
 
        msg->count = 2;
        msg->val[0] = timezone->x_coord;
@@ -614,7 +612,7 @@ void WorldClockView::UpdateTimezoneArea(const model::Timezone *timezone)
 
        edje_object_message_send(elm_layout_edje_get(world_clock_map_), EDJE_MESSAGE_INT_SET,
                MESSAGE_ID_SET_TIMEZONE, (void *) msg);
-       free(msg);
+       delete[] msg;
 }
 
 void WorldClockView::CreateTimezoneDetails()