Re: [PATCH v3 14/18] libtraceeval histogram: Use stack for old copy in update

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

 



On Thu, 17 Aug 2023 13:29:26 -0600
Ross Zwisler <zwisler@xxxxxxxxxx> wrote:

> > + fail:
> > +	/* Free the new values that were added */
> > +	data_release(i, copy, types);
> > +	/* Put back the old values */
> > +	for (i--; i >= 0; i--) {
> > +		copy_traceeval_data(types + i, NULL,
> > +				    copy + i, old + i);  
> 
> should be:                          old + i, copy + i);
> 
> Right now we're copying 'copy' into 'old', but we want to be doing it the
> other way around so we restore 'copy' back to its saved state in 'old'

I need to change the parameter names to "src" and "dst" as I can't think of
"orig" and "copy" as which direction they go. I looked at that three times,
and still am confused. And probably reverse them too to make it equivalent
to memcpy():

>From memcpy() man page;

SYNOPSIS
       #include <string.h>

       void *memcpy(void *restrict dest, const void *restrict src, size_t n);

DESCRIPTION
       The memcpy() function copies n bytes from memory area src to memory
       area dest.  The memory areas must not overlap.  Use memmove(3) if
       the memory areas do overlap.

As most standard libraries have it "dst, src" I'm pretty much thinking that
way, and my "direction" is always dst = src --> dst, src. And that's
exactly what I was thinking above :-p

-- Steve




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

  Powered by Linux