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>