diff options
author | Michal Skorupinski <m.skorupinsk@samsung.com> | 2018-07-17 16:34:09 +0200 |
---|---|---|
committer | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2018-07-18 15:02:12 +0000 |
commit | c91d7be2f191d85cdf72ec94454010128ce6b562 (patch) | |
tree | 2ccf83fbb12346e4d41dc6f76b6fdb0d299b6da9 | |
parent | 8661cb0549bc1c3551373ecb94e10f268496dd03 (diff) | |
download | gear-racing-controller-c91d7be2f191d85cdf72ec94454010128ce6b562.tar.gz gear-racing-controller-c91d7be2f191d85cdf72ec94454010128ce6b562.tar.bz2 gear-racing-controller-c91d7be2f191d85cdf72ec94454010128ce6b562.zip |
Removed controller memory allocation
Change-Id: Ib9738999c9a2e4aa843c7fbe912ee37b499a1556
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
-rw-r--r-- | src/controller/controller_car_selection.c | 9 | ||||
-rw-r--r-- | src/controller/controller_connect_to_car.c | 9 | ||||
-rw-r--r-- | src/controller/controller_connection_successed.c | 7 | ||||
-rw-r--r-- | src/controller/controller_emergency_stop.c | 7 | ||||
-rw-r--r-- | src/controller/controller_help.c | 7 | ||||
-rw-r--r-- | src/controller/controller_name_input.c | 7 | ||||
-rw-r--r-- | src/controller/controller_network_failure.c | 7 | ||||
-rw-r--r-- | src/controller/controller_racing.c | 13 | ||||
-rw-r--r-- | src/controller/controller_reset.c | 9 |
9 files changed, 32 insertions, 43 deletions
diff --git a/src/controller/controller_car_selection.c b/src/controller/controller_car_selection.c index 4ade1e2..ab4ec9b 100644 --- a/src/controller/controller_car_selection.c +++ b/src/controller/controller_car_selection.c @@ -19,11 +19,11 @@ #include "controller/controller_car_selection.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_car_selection_destroy(void) { - free(controller); + //TODO: deinit controller } static void _car_connected_cb(s_model_car_connection_cb_data *model_data) @@ -33,13 +33,12 @@ static void _car_connected_cb(s_model_car_connection_cb_data *model_data) static void _cloud_connection_cb(s_model_cloud_connection_cb_data *model_data) { - controller->view_update_cb(model_data->name); + s_info.view_update_cb(model_data->name); } void controller_car_selection_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_cloud_connection_cb); model_car_connection_subscribe_event(_car_connected_cb); diff --git a/src/controller/controller_connect_to_car.c b/src/controller/controller_connect_to_car.c index 0edc0b7..2a582dd 100644 --- a/src/controller/controller_connect_to_car.c +++ b/src/controller/controller_connect_to_car.c @@ -21,11 +21,11 @@ #include "view_manager/view_manager.h" #include "log.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_connect_to_car_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -36,10 +36,7 @@ static void _connected_cb(s_model_cloud_connection_cb_data *model_data) void controller_connect_to_car_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - ASSERT_MEMORY(!controller); - - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } diff --git a/src/controller/controller_connection_successed.c b/src/controller/controller_connection_successed.c index 62b802a..b507fd0 100644 --- a/src/controller/controller_connection_successed.c +++ b/src/controller/controller_connection_successed.c @@ -19,11 +19,11 @@ #include "controller/controller_connection_successed.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void _connection_successed_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -34,8 +34,7 @@ static void _connected_cb(s_model_cloud_connection_cb_data *model_data) void controller_connection_successed_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } diff --git a/src/controller/controller_emergency_stop.c b/src/controller/controller_emergency_stop.c index 757957c..006a0d3 100644 --- a/src/controller/controller_emergency_stop.c +++ b/src/controller/controller_emergency_stop.c @@ -21,11 +21,11 @@ #include "controller/controller_emergency_stop.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_emergency_stop_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -36,8 +36,7 @@ static void _connected_cb(s_model_cloud_connection_cb_data *model_data) void controller_emergency_stop_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } diff --git a/src/controller/controller_help.c b/src/controller/controller_help.c index 38af801..ae53930 100644 --- a/src/controller/controller_help.c +++ b/src/controller/controller_help.c @@ -21,11 +21,11 @@ #include "controller/controller_help.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_help_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -36,8 +36,7 @@ static void _connected_cb(s_model_cloud_connection_cb_data *model_data) void controller_help_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } diff --git a/src/controller/controller_name_input.c b/src/controller/controller_name_input.c index 30298bc..d6801ec 100644 --- a/src/controller/controller_name_input.c +++ b/src/controller/controller_name_input.c @@ -21,11 +21,11 @@ #include "controller/controller_name_input.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_name_input_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -36,8 +36,7 @@ static void _connected_cb(s_model_cloud_connection_cb_data *model_data) void controller_name_input_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } diff --git a/src/controller/controller_network_failure.c b/src/controller/controller_network_failure.c index ee5b90c..dca49f6 100644 --- a/src/controller/controller_network_failure.c +++ b/src/controller/controller_network_failure.c @@ -19,11 +19,11 @@ #include "controller/controller_network_failure.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_network_failure_destroy(void) { - free(controller); + //TODO: deinit controller model_cloud_connection_subscribe_reconnect(NULL); } @@ -41,8 +41,7 @@ static void _reconnected_cb(s_model_cloud_connection_cb_data *model_data) void controller_network_failure_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); model_cloud_connection_subscribe_reconnect(_reconnected_cb); diff --git a/src/controller/controller_racing.c b/src/controller/controller_racing.c index 26061d8..6f2409b 100644 --- a/src/controller/controller_racing.c +++ b/src/controller/controller_racing.c @@ -25,12 +25,12 @@ typedef struct _s_racing_controller { s_controller_data controller_data; } s_racing_controller; -static s_racing_controller *controller = NULL; +static s_racing_controller s_info = { { 0, } }; static void controller_racing_destroy(void) { model_sensors_unsubscirbe_event(); - free(controller); + //TODO: deinit controller } static void _model_connected_cb(s_model_cloud_connection_cb_data *model_data) @@ -41,16 +41,15 @@ static void _model_connected_cb(s_model_cloud_connection_cb_data *model_data) static void _sensors_cb(s_model_sensors_cb_data *model_data) { - controller->controller_data.direction = model_data->direction; - controller->controller_data.velocity = model_data->velocity; + s_info.controller_data.direction = model_data->direction; + s_info.controller_data.velocity = model_data->velocity; - controller->base_controller.view_update_cb(&controller->controller_data); + s_info.base_controller.view_update_cb(&s_info.controller_data); } void controller_racing_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_racing_controller)); - controller->base_controller.view_update_cb = view_update_cb; + s_info.base_controller.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_model_connected_cb); model_sensors_subscribe_event(_sensors_cb); diff --git a/src/controller/controller_reset.c b/src/controller/controller_reset.c index 71d0bc3..1b32374 100644 --- a/src/controller/controller_reset.c +++ b/src/controller/controller_reset.c @@ -21,23 +21,22 @@ #include "controller/controller_reset.h" #include "view_manager/view_manager.h" -static s_controller *controller = NULL; +static s_controller s_info = { 0, }; static void controller_reset_destroy(void) { - free(controller); + //TODO: deinit controller } static void _connected_cb(s_model_cloud_connection_cb_data *model_data) { - view_manager_set_view(VIEW_NAME_INPUT); controller_reset_destroy(); + view_manager_set_view(VIEW_NAME_INPUT); } void controller_reset_init(t_view_update_cb view_update_cb) { - controller = calloc(1, sizeof(s_controller)); - controller->view_update_cb = view_update_cb; + s_info.view_update_cb = view_update_cb; model_cloud_connection_subscribe_event(_connected_cb); } |