Modify to use hal_backend_sensor_funcs allocated from caller 88/313888/1 accepted/tizen_unified_dev accepted/tizen_unified_x_asan accepted/tizen/9.0/unified/20241030.233628 accepted/tizen/unified/20240704.075651 accepted/tizen/unified/dev/20240708.001614 accepted/tizen/unified/x/20241218.081936 accepted/tizen/unified/x/asan/20241224.003804 tizen_9.0_m2_release
authorSangYoun Kwak <sy.kwak@samsung.com>
Wed, 3 Jul 2024 07:35:20 +0000 (16:35 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Wed, 3 Jul 2024 07:35:20 +0000 (16:35 +0900)
With HAL ABI versioning, the hal_backend_sensor_funcs, which is a
container of sensor backend functions is allocated from hal-api-sensor.
Thus, it is modified to use hal_backend_sensor_funcs allocated from the
caller(hal-api-sensor).

Change-Id: I6ad5c106f6848d8a2064ede8d90bfb5eb11e4adf
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/hal-backend-sensor.cpp

index a5221728e43e68bfad200e0c1bd5924cd47532d6..2a721a2a25f9b439736eedcf90dc9c37ff0146bc 100644 (file)
@@ -66,23 +66,25 @@ static int sensor_emulator_create(sensor_device_t **devices) {
 
 static int sensor_emulator_init(void **data) {
   _I("init hal backend sensor");
-  hal_backend_sensor_funcs *funcs;
+  hal_backend_sensor_funcs *funcs = NULL;
 
-  funcs =
-      (hal_backend_sensor_funcs *)calloc(1, sizeof(hal_backend_sensor_funcs));
-  if (!funcs) return -ENOMEM;
+  if (!data) {
+    _E("Invalid parameter");
+    return -EINVAL;
+  }
 
-  funcs->create = sensor_emulator_create;
+  funcs = *((hal_backend_sensor_funcs **)data);
+  if (!funcs) {
+    _E("Invalid parameter");
+    return -EINVAL;
+  }
 
-  *data = (void *)funcs;
+  funcs->create = sensor_emulator_create;
 
   return 0;
 }
 
 static int sensor_emulator_exit(void *data) {
-  if (!data) return -EINVAL;
-  free(data);
-
   return 0;
 }