pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael.paquier@gmail.com>
To: Thomas Munro <thomas.munro@enterprisedb.com>
Cc: Robert Haas <rhaas@postgresql.org>
Cc: pgsql-committers@postgresql.org
Subject: Re: pgsql: Add new function dsa_allocate0.
Date: Fri, 17 Feb 2017 12:09:20 +0900
Message-ID: <CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com> (raw)
In-Reply-To: <CAEepm=0soDK45-O6itxMH2QE+bVp6QvMuxVSnRu51AUxdDivDA@mail.gmail.com>
References: <E1ceQOJ-0003cQ-W1@gemulon.postgresql.org>
	<CAEepm=1maeY16J2KTwjHvqgs5-5eT3OWYUbE9YqaaE8w5EEtFg@mail.gmail.com>
	<CAEepm=0soDK45-O6itxMH2QE+bVp6QvMuxVSnRu51AUxdDivDA@mail.gmail.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>

On Fri, Feb 17, 2017 at 12:03 PM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:
> On Fri, Feb 17, 2017 at 11:34 AM, Thomas Munro
> <thomas.munro@enterprisedb.com> wrote:
>> On Fri, Feb 17, 2017 at 7:02 AM, Robert Haas <rhaas@postgresql.org> wrote:
>>> http://git.postgresql.org/pg/commitdiff/9acb85597f1223ac26a5b19a9345849c43d0ff54
>> Hmm.  This will segfault if you're out of memory.
>
> Or to provide a more useful response... maybe this should be like the
> attached?  Or maybe people think that dsa_allocate should throw on
> failure to allocate, like palloc?

     dp = dsa_allocate(area, size);
-    object = dsa_get_address(area, dp);
-    memset(object, 0, size);
+    if (DsaPointerIsValid(dp))
+        memset(dsa_get_address(area, dp), 0, size);
What you are proposing here looks like the right answer to me. Like
dsa_allocate, dsa_allocate0 should allow users to fallback to other
methods if what is returned is InvalidDsaPointer for consistency.
-- 
Michael


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers



view thread (11+ messages)  latest in thread

Message-ID: <CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com>
Permalink:  ../CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com/
Also on:    postgresql.org/message-id/CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com

 · 

reply

Reply instructions:

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

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: michael.paquier@gmail.com, thomas.munro@enterprisedb.com, rhaas@postgresql.org
  Subject: Re: pgsql: Add new function dsa_allocate0.
  In-Reply-To: <CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com>
  References: <E1ceQOJ-0003cQ-W1@gemulon.postgresql.org> <CAEepm=1maeY16J2KTwjHvqgs5-5eT3OWYUbE9YqaaE8w5EEtFg@mail.gmail.com> <CAEepm=0soDK45-O6itxMH2QE+bVp6QvMuxVSnRu51AUxdDivDA@mail.gmail.com> <CAB7nPqTYsbw07vOEPpocUtNoeq6eACdonhGtHv-cuUiz65X16w@mail.gmail.com>

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

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox