All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH 1/2] add macro REALLOCARRAY
Date: Tue, 16 Sep 2014 12:27:38 -0700	[thread overview]
Message-ID: <xmqqy4tj1i39.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <541886D5.8060202@web.de> (=?utf-8?Q?=22Ren=C3=A9?= Scharfe"'s message of "Tue, 16 Sep 2014 20:52:05 +0200")

René Scharfe <l.s.r@web.de> writes:

> Am 16.09.2014 um 05:04 schrieb Junio C Hamano:
>> On Sun, Sep 14, 2014 at 9:55 AM, René Scharfe <l.s.r@web.de> wrote:
>>> +#define REALLOCARRAY(x, alloc) x = xrealloc((x), (alloc) * sizeof(*(x)))
>>
>> I have been wondering if "x" could be an expression that has an operator
>> that binds weaker than the assignment '='.  That may necessitate the LHS
>> of the assignment to be somehow marked as bound the tightest, i.e.
>>
>> #define REALLOC_ARRAY(x, alloc) (x) = xrealloc((x), (alloc) * sizeof(*(x)))
>>
>> Or am I being overly silly?
>
> ALLOC_GROW did well without that.  I can't think of a good use case
> for a complex expression on the right-hand side.  That said, I think I
> still have a spare matching pair of parentheses lying around here
> somewhere, so let's play it safe and use them. :)

Yeah, as long as (any) is still an lvalue for any lvalue for
everybody's compiler, (x) = ... expression ... is safer, but
taking cue from ALLOC_GROW(), I would say I was probably being
slightly overly silly.

      parent reply	other threads:[~2014-09-16 19:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-14 16:55 [PATCH 1/2] add macro REALLOCARRAY René Scharfe
2014-09-14 16:57 ` [PATCH 2/2] use REALLOCARRAY for changing the allocation size of arrays René Scharfe
2014-09-15 18:24 ` [PATCH 1/2] add macro REALLOCARRAY Junio C Hamano
2014-09-17  8:17   ` Jeff King
2014-09-16  3:04 ` Junio C Hamano
2014-09-16 18:52   ` René Scharfe
2014-09-16 18:56     ` [PATCH 1/2] add macro REALLOC_ARRAY René Scharfe
2014-09-24  7:32       ` Michael Haggerty
2014-09-24 17:59         ` Junio C Hamano
2014-09-24 19:27         ` René Scharfe
2014-09-16 18:56     ` [PATCH 2/2] use REALLOC_ARRAY for changing the allocation size of arrays René Scharfe
2014-09-24 18:47       ` Jonathan Nieder
2014-09-24 19:27         ` René Scharfe
2014-09-16 19:27     ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy4tj1i39.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=l.s.r@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.