halapi: Replace destructor with reference count method to free memory 93/253193/4
authorChanwoo Choi <cw00.choi@samsung.com>
Thu, 4 Feb 2021 06:53:40 +0000 (15:53 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 8 Feb 2021 07:11:08 +0000 (16:11 +0900)
commit97ebf2bd65d29366d2038415ad6e1ad4b4bbb228
tree91c5034fa46a52ef5770e8b4ba7695ecdb2750fa
parent080fa01f71452ddf70f84372e3a6c2bf9796680b
halapi: Replace destructor with reference count method to free memory

Instead of destructor method to free the memory, use the reference count
method to free the memory in order to support multi-thread environment.

So that define the _hal_api_conf_(init|exit)() functions to control
the reference count. These functions either get the resources from hal-api.json
or put the resources according to the reference count.
- _hal_api_conf_init() increments the reference count
- _hal_api_conf_exit() decrements the reference count

hal_common_get_backend() and hal_common_put_backend() functions should
be called pairly in order to free the resources of hal-api.json.

[Detailed use-case of _hal_api_conf_init() and _hal_api_conf_ext()]
hal_common_get_backend()
_hal_api_conf_init()
/* codes */

hal_common_put_backend()
/* codes */
_hal_api_conf_exit()

hal_common_get_backend_library_name()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

hal_common_get_backend_symbol_name()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

hal_common_check_backend_abi_version()
_hal_api_conf_init()
/* codes */
_hal_api_conf_exit()

And change the prototype of hal_common_get_backend_library_name,
hal_common_get_backend_symbol_name as following:
- int hal_common_get_backend_library_name(enum hal_module module, char *name, int size);
- int hal_common_get_backend_symbol_name(enum hal_module module, char *name, int size);

Change-Id: If663b87244cc680d94568818d4358a7b91fb071e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
haltests/src/test_hal.cc
include/hal-common.h
src/hal-api-common.c
src/hal-api-conf.c
src/hal-api-conf.h