summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangYoun Kwak <sy.kwak@samsung.com>2024-07-03 14:19:02 +0900
committerSangYoun Kwak <sy.kwak@samsung.com>2024-07-03 16:27:35 +0900
commitc9becb7b7447e24315ee33d1b3a059e000531729 (patch)
tree4d33124db1da6e38a7efee1856396c58e30a6a71
parent058eb06604c9e0bdf08e552fd0782a404b225212 (diff)
downloadsensor-accepted/tizen_unified_x.tar.gz
sensor-accepted/tizen_unified_x.tar.bz2
sensor-accepted/tizen_unified_x.zip
Previously, the memory for hal backend sensor function was allocated from the hal backend. With new hal ABI versioning, it should be allocated from the hal api. Thus, it is modified to allocate every required memories for hal backend functions in this hal api sensor. Change-Id: Ic001081d03866630423db717d35f2558f8c8a0eb Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
-rw-r--r--src/hal-api-sensor.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/hal-api-sensor.cpp b/src/hal-api-sensor.cpp
index 02a88b5..7357cf7 100644
--- a/src/hal-api-sensor.cpp
+++ b/src/hal-api-sensor.cpp
@@ -84,18 +84,28 @@ int hal_sensor_get_backend(void)
goto FREE_MEMORY;
}
- hal_sensor_funcs = (hal_backend_sensor_funcs **)malloc(sizeof(hal_backend_sensor_funcs *) * hal_sensor_count);
+ hal_sensor_funcs = (hal_backend_sensor_funcs **)calloc(hal_sensor_count, sizeof(*hal_sensor_funcs));
if (!hal_sensor_funcs) {
_E("Failed to allocate memory.");
goto FREE_MEMORY;
}
for(i = 0; i < hal_sensor_count; i++) {
+ hal_sensor_funcs[i] = (hal_backend_sensor_funcs *)calloc(1, sizeof(**hal_sensor_funcs));
+ if (!hal_sensor_funcs[i]) {
+ _E("Failed to allocate memory.");
+ goto FREE_MEMORY;
+ }
+ }
+
+ for(i = 0; i < hal_sensor_count; i++) {
ret_getbackend = hal_common_get_backend_with_library_name(HAL_MODULE_SENSOR, (void **)&hal_sensor_funcs[i], hal_sensor_names[i]);
if (ret_getbackend < 0) {
_E("Failed to get backend (%s)", hal_sensor_names[i]);
- } else
+ FREE(hal_sensor_funcs[i]);
+ } else {
loaded_backend++;
+ }
}
if (loaded_backend == 0) {
@@ -107,6 +117,12 @@ int hal_sensor_get_backend(void)
return 0;
FREE_MEMORY:
+ if (hal_sensor_funcs != NULL) {
+ for (int i = 0; i < hal_sensor_count; ++i)
+ FREE(hal_sensor_funcs[i]);
+ FREE(hal_sensor_funcs);
+ }
+
for(i = 0; i < hal_sensor_count; i++)
FREE(hal_sensor_names[i]);
@@ -127,6 +143,7 @@ int hal_sensor_put_backend(void)
for (i = 0; i < hal_sensor_count; i++) {
if (hal_sensor_funcs[i]) {
hal_common_put_backend_with_library_name(HAL_MODULE_SENSOR, (void *)hal_sensor_funcs[i], hal_sensor_names[i]);
+ FREE(hal_sensor_funcs[i]);
}
FREE(hal_sensor_names[i]);
}