On Tue, 15 Aug 2023 13:48:09 -0600 Ross Zwisler <zwisler@xxxxxxxxxx> wrote: > On Fri, Aug 11, 2023 at 01:39:32AM -0400, Steven Rostedt wrote: > > From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> > > > > When initializing the traceeval descriptor, mark each key and value as > > their type via the flags (keys get TRACEEVAL_FL_KEY and values get > > TRACEEVAL_FL_VALUE) as well as adding the index of that key/value type of > > the key/value data it represents. This will be used by the iterators for > > sorting. The iterator will point to the key/value type and use that > > information to know which key/value data to sort with. > > > > The keys and values passed in will also be updated to have their flags > > match the proper key/value type as well as the index. This will be useful > > for traceeval_stat() that will take the type as a parameter, and use it to > > figure out fast where the data is that is to be looked up. > > > > All pointer and dynamic types in keys must have both a cmp and hash > > function defined, otherwise they cannot be indexed or hashed. Add a check > > to make sure all key types of pointer and dynamic have those functions. > > > > Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> > > --- > > include/traceeval-hist.h | 11 +++++--- > > src/histograms.c | 60 ++++++++++++++++++++++++++++++++++++++-- > > 2 files changed, 64 insertions(+), 7 deletions(-) > > > > diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h > > index 4baed4237787..1c02f3039809 100644 > > --- a/include/traceeval-hist.h > > +++ b/include/traceeval-hist.h > <> > > @@ -248,6 +292,16 @@ struct traceeval *traceeval_init(const struct traceeval_type *keys, > > goto fail; > > } > > > > + ret = check_keys(keys); > > + if (ret < 0) > > + goto fail; > > + > > + if (vals) { > > + ret = check_vals(vals); > > + if (ret < 0) > > + goto fail; > > These two goto statements should both be to fail_release so we clean up > 'teval', else we could do this check above the alloc. Nice catch. Will fix. -- Steve > > > + } > > + > > /* alloc key types */ > > teval->nr_key_types = type_alloc(keys, &teval->key_types); > > if (teval->nr_key_types <= 0) { > > -- > > 2.40.1 > >