Re: [PATCH BlueZ 4/9] mesh: Generalize mesh-config APIs

Michał Lowas-Rzechonek
2019-07-10T15:01:30Z

On 07/10, Michał Lowas-Rzechonek wrote:
> mesh-config.h:
> union mesh_config;
>
> union mesh_config *mesh_config_create_config(void);
> void mesh_config_release_config(union mesh_config *config);
>
> mesh-config-json.c:
> union mesh_config {
> json_object *json
> };
>
> union mesh_config *mesh_config_create_config(void)
> {
> return (union mesh_config*)json_object_new_object();
> }
>
> void mesh_config_release_config(union mesh_config *cfg)
> {
> json_object *jnode = (json_object *)cfg;
>
> if (!cfg)
> return;
>
> json_object_put(jnode);
> }

Or even simpler, since we don't even need to define the mesh_config:

mesh-config.h
struct mesh_config;

struct mesh_config *mesh_config_create_config(void);
void mesh_config_release_config(struct mesh_config *config);

struct mesh_config *mesh_config_create_config(void)
{
return (struct mesh_config*)json_object_new_object();
}

void mesh_config_release_config(struct mesh_config *cfg)
{
json_object *jnode = (json_object *)cfg;
}

--
Michał Lowas-Rzechonek <michal.lowas-rzechonek@silvair.com>
Silvair http://silvair.com
Jasnogórska 44, 31-358 Krakow, POLAND