get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2196025/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2196025,
    "url": "http://patchwork.ozlabs.org/api/patches/2196025/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260212182031.107003-4-eggert@cs.ucla.edu/",
    "project": {
        "id": 41,
        "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api",
        "name": "GNU C Library",
        "link_name": "glibc",
        "list_id": "libc-alpha.sourceware.org",
        "list_email": "libc-alpha@sourceware.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260212182031.107003-4-eggert@cs.ucla.edu>",
    "list_archive_url": null,
    "date": "2026-02-12T18:18:13",
    "name": "[v3,3/4] Say malloc (0) != NULL is now common; resection",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "fc0a12bea6ca76c177cabb21abe921b0dc256d73",
    "submitter": {
        "id": 4434,
        "url": "http://patchwork.ozlabs.org/api/people/4434/?format=api",
        "name": "Paul Eggert",
        "email": "eggert@CS.UCLA.EDU"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260212182031.107003-4-eggert@cs.ucla.edu/mbox/",
    "series": [
        {
            "id": 492003,
            "url": "http://patchwork.ozlabs.org/api/series/492003/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=492003",
            "date": "2026-02-12T18:18:14",
            "name": "malloc doc fixes for alignment",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/492003/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2196025/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2196025/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@legolas.ozlabs.org",
            "libc-alpha@sourceware.org"
        ],
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=cs.ucla.edu header.i=@cs.ucla.edu header.a=rsa-sha256\n header.s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C header.b=VZYHc7WA;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)",
            "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=cs.ucla.edu header.i=@cs.ucla.edu header.a=rsa-sha256\n header.s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C header.b=VZYHc7WA",
            "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=cs.ucla.edu",
            "sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu",
            "server2.sourceware.org;\n arc=none smtp.remote-ip=131.179.128.66",
            "mail.cs.ucla.edu (amavis); dkim=pass (2048-bit key)\n header.d=cs.ucla.edu"
        ],
        "Received": [
            "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fBkJm6rZ2z1xr1\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 05:26:16 +1100 (AEDT)",
            "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id E209D4B9DB48\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 12 Feb 2026 18:26:14 +0000 (GMT)",
            "from mail.cs.ucla.edu (mail.cs.ucla.edu [131.179.128.66])\n by sourceware.org (Postfix) with ESMTPS id CACBB4BA2E16\n for <libc-alpha@sourceware.org>; Thu, 12 Feb 2026 18:20:59 +0000 (GMT)",
            "from localhost (localhost [127.0.0.1])\n by mail.cs.ucla.edu (Postfix) with ESMTP id 3E9583C03E9EA;\n Thu, 12 Feb 2026 10:20:59 -0800 (PST)",
            "from mail.cs.ucla.edu ([127.0.0.1])\n by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10032) with ESMTP\n id G5sY9OXffNFx; Thu, 12 Feb 2026 10:20:59 -0800 (PST)",
            "from localhost (localhost [127.0.0.1])\n by mail.cs.ucla.edu (Postfix) with ESMTP id 189533C03E9F0;\n Thu, 12 Feb 2026 10:20:59 -0800 (PST)",
            "from mail.cs.ucla.edu ([127.0.0.1])\n by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavis, port 10026) with ESMTP\n id SLqWPqYBRmEx; Thu, 12 Feb 2026 10:20:59 -0800 (PST)",
            "from wing.home (47-154-25-30.fdr01.snmn.ca.ip.frontiernet.net\n [47.154.25.30])\n by mail.cs.ucla.edu (Postfix) with ESMTPSA id F411E3C03E9EA;\n Thu, 12 Feb 2026 10:20:58 -0800 (PST)"
        ],
        "DKIM-Filter": [
            "OpenDKIM Filter v2.11.0 sourceware.org E209D4B9DB48",
            "OpenDKIM Filter v2.11.0 sourceware.org CACBB4BA2E16",
            "OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 189533C03E9F0"
        ],
        "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org CACBB4BA2E16",
        "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org CACBB4BA2E16",
        "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770920459; cv=none;\n b=HDn4z64rpMzDdAgUyHj/6iqviGepp1VweqPGXcXFEkZBleNN8z0JzUrWxXJ2AuCLMsr1M5mBF4JRdajV8Yh0AZw2uTnN6F6EyqVxf79if/rT7s3rlpvM0Ows9y5/2TE9e9vUnz4O3DiRsjXC1rI8RwoTURYaeHXT0zwmwG91PFA=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1770920459; c=relaxed/simple;\n bh=OnxPP1fEYIwGQqby2RW3AAt3RQ/ZI57q8GzfxnqpG70=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=O5EDKPoMjAJNTU1PvhRVNCoF+4cMUckP7OPo8tdwc9xUJc8DpeAjfUYze5wES90iL5o29sfvOMBqv3bnz/0xdJFnGjEMtxCRARwTpzZS0uKvnQAohitCTXN6zYZ+kP/a9cnSXLT6bOJbqsexEYTy/eYPtbpuaQupxo9tWhkGYrU=",
        "ARC-Authentication-Results": "i=1; server2.sourceware.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu;\n s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1770920459;\n bh=+pB2PZV2NLtPljDf76QOG8XCm63ZujRelidvxcuNeWg=;\n h=From:To:Date:Message-ID:MIME-Version;\n b=VZYHc7WADPZ8ScGrUYoiPtNbk0y/iQdkv/faCH8cULuTMQk2kAsUsYiKyglaDhuFo\n +PBGXFAE+tcEjDLw9JKC5P9eXk30lOodjvaNXY5qaCP/ibdGRJMDLQz4kMUyYEWRaQ\n Myp4AZR/bBeYU/q0rQv0b17tfnv5l7bv2kw+2imuDDFZjQakQf+F5tpszHnQLHKVP/\n AEg8+HD7VTpJcn/lJzcG6McWICFCBPk0qbLK+NNGFia6bnFxFbKBWmnH9fuc/fTLVC\n k6So+Q720j0FzmZbpSfhrXyqRJbtihPc3ZAschc83dFxeCxH+Mj53+OyFNFODx0czV\n hQx/iJfA0rPTA==",
        "X-Virus-Scanned": "amavis at mail.cs.ucla.edu",
        "From": "Paul Eggert <eggert@cs.ucla.edu>",
        "To": "libc-alpha@sourceware.org",
        "Cc": "Paul Eggert <eggert@cs.ucla.edu>",
        "Subject": "[PATCH v3 3/4] Say malloc (0) != NULL is now common; resection",
        "Date": "Thu, 12 Feb 2026 10:18:13 -0800",
        "Message-ID": "<20260212182031.107003-4-eggert@cs.ucla.edu>",
        "X-Mailer": "git-send-email 2.51.0",
        "In-Reply-To": "<20260212182031.107003-1-eggert@cs.ucla.edu>",
        "References": "<20260212182031.107003-1-eggert@cs.ucla.edu>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "quoted-printable",
        "X-BeenThere": "libc-alpha@sourceware.org",
        "X-Mailman-Version": "2.1.30",
        "Precedence": "list",
        "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>",
        "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>",
        "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>",
        "List-Post": "<mailto:libc-alpha@sourceware.org>",
        "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>",
        "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>",
        "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org"
    },
    "content": "* manual/memory.texi (Portable Allocation):\nNew section, split off from Malloc Examples.\nSay that almost every system follows glibc's example\nin having successful malloc (0) return non-null;\nAIX is the only exception nowadays.\nDocument fundamental alignment portability.\nHave examples match the new text, and use NULL rather than 0.\n---\n manual/memory.texi | 130 +++++++++++++++++++++++++++++++--------------\n 1 file changed, 91 insertions(+), 39 deletions(-)",
    "diff": "diff --git a/manual/memory.texi b/manual/memory.texi\nindex 614cdc4e46..935df79e9c 100644\n--- a/manual/memory.texi\n+++ b/manual/memory.texi\n@@ -318,6 +318,7 @@ any time (or never).\n @menu\n * Basic Allocation::            Simple use of @code{malloc}.\n * Malloc Examples::             Examples of @code{malloc}.  @code{xmalloc}.\n+* Portable Allocation::         Portable use of @code{malloc}.\n * Freeing after Malloc::        Use @code{free} to free a block you\n \t\t\t\t got with @code{malloc}.\n * Changing Block Size::         Use @code{realloc} to make a block\n@@ -621,7 +622,7 @@ If no more space is available, @code{malloc} returns a null pointer.\n You should check the value of @emph{every} call to @code{malloc}.  It is\n useful to write a subroutine that calls @code{malloc} and reports an\n error if the value is a null pointer, returning only if the value is\n-nonzero.  This function is conventionally called @code{xmalloc}.  Here\n+non-null.  This function is conventionally called @code{xmalloc}.  Here\n it is:\n @cindex @code{xmalloc} function\n \n@@ -629,10 +630,10 @@ it is:\n void *\n xmalloc (size_t size)\n @{\n-  void *value = malloc (size);\n-  if (value == 0)\n+  void *p = malloc (size);\n+  if (p == NULL)\n     fatal (\"virtual memory exhausted\");\n-  return value;\n+  return p;\n @}\n @end smallexample\n \n@@ -645,9 +646,9 @@ a newly allocated null-terminated string:\n char *\n savestring (const char *ptr, size_t len)\n @{\n-  char *value = xmalloc (len + 1);\n-  value[len] = '\\0';\n-  return memcpy (value, ptr, len);\n+  char *p = xmalloc (len + 1);\n+  p[len] = '\\0';\n+  return memcpy (p, ptr, len);\n @}\n @end group\n @end smallexample\n@@ -669,19 +670,44 @@ contents of another block.  If you have already allocated a block and\n discover you want it to be bigger, use @code{realloc} (@pxref{Changing\n Block Size}).\n \n-@strong{Portability Notes:}\n+@node Portable Allocation\n+@subsubsection Portable Memory Allocation\n+\n+More care is needed when allocating memory in\n+code intended to run on both GNU and non-GNU systems,\n+or when a non-GNU replacement allocator is used (@pxref{Replacing malloc}).\n+When storage size is small or outlandishly large,\n+or when storage is allocated for a less-common type,\n+the POSIX and ISO C standards permit multiple behaviors.\n \n @itemize @bullet\n @item\n-In @theglibc{}, a successful @code{malloc (0)}\n-returns a non-null pointer to a newly allocated size-zero block;\n-other implementations may return @code{NULL} instead.\n-POSIX and the ISO C standard allow both behaviors.\n+In most systems, a successful @code{malloc (0)}\n+returns a non-null pointer to a newly allocated size-zero block.\n+However, IBM AIX is unusual in that a successful @code{malloc (0)}\n+returns a null pointer, and this breaks common code such as the\n+implementation of @code{xmalloc} given in this manual.  @xref{Malloc Examples}.\n+Code intended to be portable to IBM AIX can use\n+@code{p = malloc (size | (size == 0))} instead of @code{p = malloc (size)},\n+or if it does not mind a null pointer on success it can replace the following\n+@code{if (p == NULL) fatal (...);} with\n+@code{if (p == NULL && size != 0) fatal (...);}.\n \n @item\n-In @theglibc{}, a non-null pointer returned by @code{malloc (@var{size})}\n-is a multiple of @code{alignof (max_align_t)} when converted to an integer.\n-Other implementations may align the result only to what is needed for\n+In @theglibc{}, a failed @code{malloc} call sets @code{errno},\n+but ISO C does not require this and non-POSIX implementations\n+need not set @code{errno} when failing.\n+\n+@item\n+In @theglibc{}, @code{malloc} always fails when @var{size} exceeds\n+@code{PTRDIFF_MAX}, to avoid problems with programs that subtract\n+pointers or use signed indexes.  Other implementations may succeed in\n+this case, leading to undefined behavior later.\n+\n+@item\n+In @theglibc{}, @code{malloc (@var{size})} returns a pointer that when\n+converted to an integer is a multiple of @code{alignof (max_align_t)}.\n+Some other implementations may align the result only to what is needed for\n fundamentally-aligned objects of size at most @code{max (@var{size}, 1)}.\n For example, if @code{alignof (max_align_t)} is 16 but smaller\n fundamentally-aligned objects all have alignment of at most 4,\n@@ -691,15 +717,36 @@ Portable code should therefore use a function like @code{aligned_alloc}\n if it needs @code{alignof (max_align_t)} alignment even for small allocations.\n \n @item\n-In @theglibc{}, a failed @code{malloc} call sets @code{errno},\n-but ISO C does not require this and non-POSIX implementations\n-need not set @code{errno} when failing.\n+Although @theglibc{}'s headers define only types with fundamental alignment,\n+the C and POSIX standards require only the following types\n+(if available) to have fundamental alignment:\n+\n+@quotation\n+@code{char};\n+all integer types (including @code{bool});\n+@code{float}, @code{double}, @code{long double};\n+@code{_Decimal32}, @code{_Decimal64}, @code{_Decimal128};\n+@code{float _Complex}, @code{double _Complex}, @code{long double _Complex};\n+all enumerated types;\n+all pointer types;\n+all array types whose element types have fundamental alignment;\n+all struct and union types whose element types all have\n+fundamental alignment and that lack stricter alignment specifiers;\n+@code{va_list} (in @code{<stdarg.h>});\n+@code{fpos_t} (in @code{<stdio.h>});\n+@code{cnd_t}, @code{thrd_t}, @code{tss_t}, @code{mtx_t}, @code{once_flag}\n+(in @code{<threads.h>});\n+@code{mbstate_t} (in @code{<wchar.h>}).\n+@end quotation\n \n-@item\n-In @theglibc{}, @code{malloc} always fails when @var{size} exceeds\n-@code{PTRDIFF_MAX}, to avoid problems with programs that subtract\n-pointers or use signed indexes.  Other implementations may succeed in\n-this case, leading to undefined behavior later.\n+@noindent\n+In theory, portable code should not use @code{malloc} to\n+allocate storage containing types not in this list;\n+it should instead use functions like @code{aligned_alloc}.\n+In practice, though, other implementations generally follow\n+@theglibc{}'s lead and define only types with fundamental alignment,\n+and it is generally portable to use @code{malloc} to allocate objects\n+with types defined by the C library.\n @end itemize\n \n @node Freeing after Malloc\n@@ -883,6 +930,8 @@ is left undisturbed.\n Any non-null pointer returned by @code{realloc} satisfies the same\n alignment restrictions as a similar pointer returned by @code{malloc}\n with the same size.\n+Any special alignment created by @code{aligned_alloc}\n+and similar functions is lost after @code{realloc}.\n @end deftypefun\n \n @deftypefun {void *} reallocarray (void *@var{ptr}, size_t @var{nmemb}, size_t @var{size})\n@@ -900,6 +949,13 @@ returning a null pointer, and leaving the original block unchanged.\n @code{reallocarray} should be used instead of @code{realloc} when the new size\n of the allocated block is the result of a multiplication that might overflow.\n \n+In @theglibc{}, the vector is aligned the same way that @code{malloc}\n+aligns its returned values.  In other implementations, it may be merely\n+aligned suitably for any array of fundamentally-aligned elements each\n+with size at most @code{max (@var{size}, 1)}.\n+Any special alignment created by @code{aligned_alloc}\n+and similar functions is lost after @code{reallocarray}.\n+\n This function was originally derived from OpenBSD 5.6, but was added in\n POSIX.1-2024.\n @end deftypefun\n@@ -922,8 +978,8 @@ as @code{xmalloc} does for @code{malloc}:\n void *\n xreallocarray (void *ptr, size_t nmemb, size_t size)\n @{\n-  void *value = reallocarray (ptr, nmemb, size);\n-  if (value == 0)\n+  void *p = reallocarray (ptr, nmemb, size);\n+  if (p == NULL)\n     fatal (\"Virtual memory exhausted\");\n   return value;\n @}\n@@ -994,15 +1050,9 @@ is declared in @file{stdlib.h}.\n @c  chunk_is_mmapped dup ok\n @c  MALLOC_ZERO ok\n @c   memset dup ok\n-This function allocates a block long enough to contain a vector of\n-@var{count} elements, each of size @var{eltsize}.  Its contents are\n-cleared to zero before @code{calloc} returns.\n-\n-In @theglibc{}, the vector is aligned the same way that @code{malloc}\n-aligns its returned values.  In other implementations, it is merely\n-aligned suitably for any array of fundamentally-aligned elements each\n-with size at most @code{max (@var{size}, 1)}.\n-\n+This function allocates a zeroed vector.  It acts like\n+@code{reallocarray (NULL, @var{count}, @var{eltsize})} except that the\n+vector's contents are cleared to zero before @code{calloc} returns.\n @end deftypefun\n \n You could define @code{calloc} as follows:\n@@ -1011,10 +1061,10 @@ You could define @code{calloc} as follows:\n void *\n calloc (size_t count, size_t eltsize)\n @{\n-  void *value = reallocarray (0, count, eltsize);\n-  if (value != 0)\n-    memset (value, 0, count * eltsize);\n-  return value;\n+  void *p = reallocarray (0, count, eltsize);\n+  if (p != NULL)\n+    memset (p, 0, count * eltsize);\n+  return p;\n @}\n @end smallexample\n \n@@ -1934,7 +1984,9 @@ functions (that is, all the functions used by the application,\n failures, and, at run time, to heap corruption and application crashes.\n Replacement functions should implement the behavior documented for\n their counterparts in @theglibc{}; for example, the replacement\n-@code{free} should also preserve @code{errno}.\n+@code{malloc} should return a null pointer only when failing,\n+it should return pointers aligned to @code{alignof (max_align_t)},\n+and the replacement @code{free} should preserve @code{errno}.\n \n The minimum set of functions which has to be provided by a custom\n @code{malloc} is given in the table below.\n",
    "prefixes": [
        "v3",
        "3/4"
    ]
}