Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ceYvG-0001ds-4g for pgsql-committers@arkaria.postgresql.org; Fri, 17 Feb 2017 03:09:26 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ceYvF-0004NT-8H for pgsql-committers@arkaria.postgresql.org; Fri, 17 Feb 2017 03:09:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ceYvE-0004NN-UN for pgsql-committers@postgresql.org; Fri, 17 Feb 2017 03:09:25 +0000 Received: from mail-vk0-x231.google.com ([2607:f8b0:400c:c05::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1ceYvC-0007aU-Le; Fri, 17 Feb 2017 03:09:24 +0000 Received: by mail-vk0-x231.google.com with SMTP id k127so22312560vke.0; Thu, 16 Feb 2017 19:09:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0gJFK4cRe/C2XzJ5GjWYUfpSyiBifkjgQ9b1s5lCLcw=; b=ZdAkdBYMzs27zQRCNKcFOnWXfga+i6ehAPVs1X5hDZ6hcVGkcOzjVsV3Q2cFv21LrQ LsgAM6XQYBC4FbpYgngLhKkvn2e/+Qe81x1iAJYnAMry/DY1cmGP5U/0RYkkY+e48uJk jeX7HthCLgN5kTprJT3lRDqVtm1Rk7Lk+9Jf3RwR2NaEXPW9w1abaK1u5R9egjJlpqah G7MOEzts6BpDicOdNVk42uHS/gn98DNfcOpOL/iS4TtPAa0skNraihZEi3FKmBBDaxrI zr0/8A5o97FPtGqAtPsKe7qlgfYsLvHpp6Z8R9tZxdl2Xe52T3mxHu6z7z5IdCD+RHhF QIMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0gJFK4cRe/C2XzJ5GjWYUfpSyiBifkjgQ9b1s5lCLcw=; b=hETyCqL16XWJa0lc5edeFKzHhQlN1fkPePSJgy13l0dyjmpSM3UZeSvrTOaiCM+p7h I3Sy5amnhyCY20Wfk9ReZrAmv5IldNb3E614SdjGsttpx4wdxAwi1BafZNvht/G5JECI UrQNLYaZ1Pbxn7xeBt01Zq6Q2XQvXoT8IlKJLTFtsI1mAdDsc31pLQ0M1QtNuJWj8Dfj fzyAtk7198DXdwbX7S2UqK2vZpuMLMiYefGGrmgaqKbXGRfEaTAvRiKi3Mdm3w9FbLM4 LMEZP8pk77/ZjLYSPbDTBlsvYr2cAwubw0RAkL61cGpQsDodSBdpL/nivpzDCwPe8ttO eabA== X-Gm-Message-State: AMke39m4qtwzda3mnuY877MWQEEpVV3+FxzqKQpEb2MF2WRp5eqaHZPl+xPw1DHVD9FSEksLtXw7qkf7l0dYuw== X-Received: by 10.31.230.131 with SMTP id d125mr2366715vkh.104.1487300960965; Thu, 16 Feb 2017 19:09:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.91.217 with HTTP; Thu, 16 Feb 2017 19:09:20 -0800 (PST) In-Reply-To: References: From: Michael Paquier Date: Fri, 17 Feb 2017 12:09:20 +0900 Message-ID: Subject: Re: pgsql: Add new function dsa_allocate0. To: Thomas Munro Cc: Robert Haas , pgsql-committers@postgresql.org Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org On Fri, Feb 17, 2017 at 12:03 PM, Thomas Munro wrote: > On Fri, Feb 17, 2017 at 11:34 AM, Thomas Munro > wrote: >> On Fri, Feb 17, 2017 at 7:02 AM, Robert Haas 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