From patchwork Tue Apr 18 23:15:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 85110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3187727vqo; Tue, 18 Apr 2023 16:16:02 -0700 (PDT) X-Google-Smtp-Source: AKy350byNAFNc8r/cfcq/lU754tmalr3KwUYTy/efpfvR3sHfVAgJEY/X+fLmAjOkEV/7Cd50/bS X-Received: by 2002:a17:906:3503:b0:94f:865d:f81f with SMTP id r3-20020a170906350300b0094f865df81fmr7576001eja.17.1681859762441; Tue, 18 Apr 2023 16:16:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681859762; cv=none; d=google.com; s=arc-20160816; b=wAZLS5WE1k4IvO3LgNhUhLCFmZFB0tZOyILAuPqotk4MwlO5JR+IRcLhEgd/6DCfev D7vg0MXUfjPtxio7afXtlT5Y7/gqCMNnbLJwMXsXLsWJJMF762JK4/LEknxQEBuLUgXU zxw7i68THZgx+psSB0wFS2o4Pu2lTP3f/16zKnamWePofm/a4AX/YWclVBQN45Svdda6 pM4+xnAOYq5tkjIKSXmc9CXD9GvvqXqqYt1YAQ3Ry4WI6oCvuns2evLPkPUwXnOWDrYB T7IZqubmW5d24K+gISMQV8HX2r45jzvECrjuhFr48N3QlWRNN1RrH+JjwrbNc94FqMZL afNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=bzod7+FDwo61NdcnFmQ3KZDeuQU0iZ78JJW6zUA13xI=; b=RP7lKFda1F0CP8X9UsAC3ruR6+MH3M0i65TjWoJdZaUp35JyfPrnADQpPeGi9dd5Sm El8ZgaI09sbfHmaXe6Mv4H2BIBjbsemmGDeBRfE7FqwzVQd/QCZ8PR1sXlr3MAhjrN7p Cp03yiEMG2egPKdsraVWmcLWuUcsojmYNqfQZ0oLqwdCG/NkdtmcVN/Zcl4+IjSk1e0e vUeOF7h9eMogrdKpQStFcqYSL+Gkkq2V/yPxDvrCq5C2cu7YIVFf3Cz8P1Pu3fmTnhtV SE93OqxNGDXpRGZQsedfUvpFJsz1Zpu/apn0or67hlAkp4dpn0aPIO1FIySfh0ryiMuL D3rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UguPa0D6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fh20-20020a1709073a9400b0094f1af74f10si6926012ejc.621.2023.04.18.16.16.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 16:16:02 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UguPa0D6; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 191CB3857732 for ; Tue, 18 Apr 2023 23:15:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 191CB3857732 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681859753; bh=bzod7+FDwo61NdcnFmQ3KZDeuQU0iZ78JJW6zUA13xI=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=UguPa0D6wPDKngR7WbbLM5uOfeG1JL3kkQH4BqOU5PMJo9UVYlK2V4Shw4/lySxRX 6aTzCSUO8z4ce+KhWzTZViAnFo0lXcMhCrEM19/xP4DYtHNsxfI0JPnaVkdeyFh9Mc BQXus7mhq6MqIgAnHVOVbx/syEmIB+tC2ItXQFGE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DA7BB3858438 for ; Tue, 18 Apr 2023 23:15:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DA7BB3858438 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-8t8yGBafMLmCon82gcay5w-1; Tue, 18 Apr 2023 19:15:01 -0400 X-MC-Unique: 8t8yGBafMLmCon82gcay5w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E611B858F0E; Tue, 18 Apr 2023 23:15:00 +0000 (UTC) Received: from localhost (unknown [10.42.28.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3AC61121314; Tue, 18 Apr 2023 23:15:00 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Adjust uses of null pointer constants in docs Date: Wed, 19 Apr 2023 00:15:00 +0100 Message-Id: <20230418231500.585632-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763557782059122012?= X-GMAIL-MSGID: =?utf-8?q?1763557782059122012?= Tested x86_64-linux. Pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * doc/xml/manual/extensions.xml: Fix example to declare and qualify std::free, and use NULL instead of 0. * doc/html/manual/ext_demangling.html: Regenerate. * libsupc++/cxxabi.h: Adjust doxygen comments. --- libstdc++-v3/doc/html/manual/ext_demangling.html | 8 +++----- libstdc++-v3/doc/xml/manual/extensions.xml | 8 +++----- libstdc++-v3/libsupc++/cxxabi.h | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libstdc++-v3/doc/html/manual/ext_demangling.html b/libstdc++-v3/doc/html/manual/ext_demangling.html index 028ec71d8c8..1e7cdda8326 100644 --- a/libstdc++-v3/doc/html/manual/ext_demangling.html +++ b/libstdc++-v3/doc/html/manual/ext_demangling.html @@ -26,6 +26,7 @@

 #include <exception>
 #include <iostream>
+#include <cstdlib>
 #include <cxxabi.h>
 
 struct empty { };
@@ -33,7 +34,6 @@ struct empty { };
 template <typename T, int N>
   struct bar { };
 
-
 int main()
 {
   int     status;
@@ -43,11 +43,9 @@ int main()
   bar<empty,17>          u;
   const std::type_info  &ti = typeid(u);
 
-  realname = abi::__cxa_demangle(ti.name(), 0, 0, &status);
+  realname = abi::__cxa_demangle(ti.name(), NULL, NULL, &status);
   std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n';
-  free(realname);
-
-  return 0;
+  std::free(realname);
 }
    

This prints diff --git a/libstdc++-v3/doc/xml/manual/extensions.xml b/libstdc++-v3/doc/xml/manual/extensions.xml index 196b55d8347..daa98f5cba7 100644 --- a/libstdc++-v3/doc/xml/manual/extensions.xml +++ b/libstdc++-v3/doc/xml/manual/extensions.xml @@ -521,6 +521,7 @@ get_temporary_buffer(5, (int*)0); #include <exception> #include <iostream> +#include <cstdlib> #include <cxxabi.h> struct empty { }; @@ -528,7 +529,6 @@ struct empty { }; template <typename T, int N> struct bar { }; - int main() { int status; @@ -538,11 +538,9 @@ int main() bar<empty,17> u; const std::type_info &ti = typeid(u); - realname = abi::__cxa_demangle(ti.name(), 0, 0, &status); + realname = abi::__cxa_demangle(ti.name(), NULL, NULL, &status); std::cout << ti.name() << "\t=> " << realname << "\t: " << status << '\n'; - free(realname); - - return 0; + std::free(realname); } diff --git a/libstdc++-v3/libsupc++/cxxabi.h b/libstdc++-v3/libsupc++/cxxabi.h index 10179bc0a0d..ac0637b0343 100644 --- a/libstdc++-v3/libsupc++/cxxabi.h +++ b/libstdc++-v3/libsupc++/cxxabi.h @@ -169,7 +169,7 @@ namespace __cxxabiv1 * @param __output_buffer A region of memory, allocated with * malloc, of @a *__length bytes, into which the demangled name is * stored. If @a __output_buffer is not long enough, it is - * expanded using realloc. @a __output_buffer may instead be NULL; + * expanded using realloc. @a __output_buffer may instead be null; * in that case, the demangled name is placed in a region of memory * allocated with malloc. * @@ -184,7 +184,7 @@ namespace __cxxabiv1 * -3: One of the arguments is invalid. * * @return A pointer to the start of the NUL-terminated demangled - * name, or NULL if the demangling fails. The caller is + * name, or a null pointer if the demangling fails. The caller is * responsible for deallocating this memory using @c free. * * The demangling is performed using the C++ ABI mangling rules,