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

Stotland, Inga
2019-07-10T15:58:22Z

[-- Attachment #1: Type: text/plain, Size: 1410 bytes --]

Hi Michal,

On Wed, 2019-07-10 at 17:01 +0200, Michał Lowas-Rzechonek wrote:
> 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;
> }
>

I agree. Defining structure forward is better.
Inga

[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 3265 bytes --]