[ 
https://issues.apache.org/jira/browse/MYNEWT-261?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15439844#comment-15439844
 ] 

Paul Dietrich commented on MYNEWT-261:
--------------------------------------

Chris,

It was so long ago.  I think I was asking for exactly what you showed as an 
example. 

Maybe my concerns was registering these stats. From a driver perspective, I I 
was probably thinking about how to dynamically create these when someone 
initialized the driver and then register with the stats module.  

STATS_SECT_DECL(my_stats) *ps = malloc(sizeof(STATS_SECT_DECL(my_stats))
stats_register("foo", ps).

So I have to pass a name as a const string since you are not copying it.

But when I do this dynamically, I have to keep that string somewhere.

Like we discussed I could do this

struct my_driver_instance {
   char *stat_name[32]
   STATS_SECT_DECL(my_stats) *ps
  /*  my other driver state */
}

And then I could sprint a stats name like

sprintf(myd->name, "mdriver%d", i)
stats_register(myd->name, myd->ps)

So I think that covers it. 

> stats module does not allow multiple instances of the same section
> ------------------------------------------------------------------
>
>                 Key: MYNEWT-261
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-261
>             Project: Mynewt
>          Issue Type: Improvement
>            Reporter: Paul Dietrich
>            Assignee: Peter Snyder
>             Fix For: v1_0_0_beta1
>
>
> Suppose I make a driver for peripheral X.  My driver supports up to 3 
> peripherals of type X.  I want each one to have a unique name.
> px_1
> px_2
> px_3
> Right now it takes a bit of fussing to do this since the stats modules does 
> not copy the name.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to