public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Add drop function on Ident struct
@ 2023-05-02  7:09 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-05-02  7:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:bf75c15d4057ae001becb94b16e4c79b0712db05

commit bf75c15d4057ae001becb94b16e4c79b0712db05
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Wed Apr 12 17:47:43 2023 +0200

    libproc_macro: Add drop function on Ident struct
    
    Add a drop function that cleans internal fields of a given Ident struct.
    
    ChangeLog:
    
            * libgrust/libproc_macro/ident.cc (Ident__drop): Replace by call
            to Ident::drop.
            (Ident::drop): Add drop function.
            * libgrust/libproc_macro/ident.h: Add drop prototype.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 libgrust/libproc_macro/ident.cc | 9 ++++++++-
 libgrust/libproc_macro/ident.h  | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libgrust/libproc_macro/ident.cc b/libgrust/libproc_macro/ident.cc
index d7d588975d7..0bed2a8e7d4 100644
--- a/libgrust/libproc_macro/ident.cc
+++ b/libgrust/libproc_macro/ident.cc
@@ -42,7 +42,7 @@ Ident__new_raw (unsigned char *str, std::uint64_t len)
 void
 Ident__drop (Ident *ident)
 {
-  delete[] ident->val;
+  Ident::drop (ident);
 }
 
 Ident
@@ -76,4 +76,11 @@ Ident::make_ident (const unsigned char *str, std::uint64_t len, bool raw)
   return {raw, val, len};
 }
 
+void
+Ident::drop (Ident *ident)
+{
+  delete[] ident->val;
+  ident->len = 0;
+}
+
 } // namespace Ident
diff --git a/libgrust/libproc_macro/ident.h b/libgrust/libproc_macro/ident.h
index 5a2a46a8c1f..0e21275863e 100644
--- a/libgrust/libproc_macro/ident.h
+++ b/libgrust/libproc_macro/ident.h
@@ -41,6 +41,8 @@ public:
   static Ident make_ident (std::string str, bool raw = false);
   static Ident make_ident (const unsigned char *str, std::uint64_t len,
 			   bool raw = false);
+
+  static void drop (Ident *ident);
 };
 
 extern "C" {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-02  7:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02  7:09 [gcc/devel/rust/master] libproc_macro: Add drop function on Ident struct Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).