]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: libproc_macro: Add drop function on Ident struct
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 12 Apr 2023 15:47:43 +0000 (17:47 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:34:11 +0000 (18:34 +0100)
Add a drop function that cleans internal fields of a given Ident struct.

libgrust/ChangeLog:

* libproc_macro/ident.cc (Ident__drop): Replace by call
to Ident::drop.
(Ident::drop): Add drop function.
* libproc_macro/ident.h: Add drop prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
libgrust/libproc_macro/ident.cc
libgrust/libproc_macro/ident.h

index d7d588975d753295b0cb3c91f4b4cd0720a3ed5e..0bed2a8e7d4deea634d9d974822f5b067a7e89b8 100644 (file)
@@ -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
index 5a2a46a8c1f77f2a533fe0b9705b670a85cb7bba..0e21275863eaa655f8cd8dbc164cf8fc8b5aac14 100644 (file)
@@ -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" {