Re: [PATCH v3 1/6] histograms: Initial histograms interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 8 Aug 2023 17:51:05 -0400
Stevie Alvarez <stevie.6strings@xxxxxxxxx> wrote:

> On Tue, Aug 08, 2023 at 03:35:47PM -0400, Steven Rostedt wrote:
> > On Tue,  8 Aug 2023 12:11:54 -0400
> > Stevie Alvarez <stevie.6strings@xxxxxxxxx> wrote:
> >   
> > > +/*
> > > + * Trace data entry for a traceeval histogram
> > > + * Constitutes keys and values.
> > > + */
> > > +union traceeval_data {
> > > +	char				*string;  
> > 
> > We need to also add:
> > 
> > 	const char			*cstring;
> > 
> > At least for the user interface, as I'm converting task-eval over to this,
> > and I need to assign const strings to this union.  
> 
> I assume I should treat cstring the same as string, execept because it's
> constant, it should not be updated on insertion, correct?

On insertion we have:

static int copy_traceeval_data(struct traceeval_type *type,
				const union traceeval_data *orig,
				union traceeval_data *copy)
{
	*copy = *orig;

	switch (type->type) {
	case TRACEEVAL_TYPE_STRING:
		copy->string = NULL;
		if (orig->string)
			copy->string = strdup(orig->string);
		if (!copy->string)
			return -1;
		break;

	default:
		break;
	}

	return 0;
}

So we copy it. That means we really can do whatever we want to it.

-- Steve



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux