From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Add bump memory context type and use it for tuplesorts |
Date: | 2024-02-20 10:52:14 |
Message-ID: | CAEze2Wh2wPsWwyo_WPZtJttX9moy++OVQvZU67iQQVn9K1En=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 20 Feb 2024 at 10:41, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Tue, 7 Nov 2023 at 07:55, Matthias van de Meent
> <boekewurm+postgres(at)gmail(dot)com> wrote:
> > > +++ b/src/backend/utils/mmgr/bump.c
> > > +BumpBlockIsEmpty(BumpBlock *block)
> > > +{
> > > + /* it's empty if the freeptr has not moved */
> > > + return (block->freeptr == (char *) block + Bump_BLOCKHDRSZ);
> > > [...]
> > > +static inline void
> > > +BumpBlockMarkEmpty(BumpBlock *block)
> > > +{
> > > +#if defined(USE_VALGRIND) || defined(CLOBBER_FREED_MEMORY)
> > > + char *datastart = ((char *) block) + Bump_BLOCKHDRSZ;
> >
> > These two use different definitions of the start pointer. Is that deliberate?
>
> hmm, I'm not sure if I follow what you mean. Are you talking about
> the "datastart" variable and the assignment of block->freeptr (which
> you've not quoted?)
What I meant was that
> (char *) block + Bump_BLOCKHDRSZ
vs
> ((char *) block) + Bump_BLOCKHDRSZ
, when combined with my little experience with pointer addition and
precedence, and a lack of compiler at the ready at that point in time,
I was afraid that "(char *) block + Bump_BLOCKHDRSZ" would be parsed
as "(char *) (block + Bump_BLOCKHDRSZ)", which would get different
offsets across the two statements.
Godbolt has since helped me understand that both are equivalent.
Kind regards,
Matthias van de Meent
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2024-02-20 10:53:20 | Re: speed up a logical replica setup |
Previous Message | Robert Haas | 2024-02-20 10:51:19 | Re: A new message seems missing a punctuation |