aboutsummaryrefslogtreecommitdiff
path: root/libgrust
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-04-12 17:47:43 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:34:11 +0100
commitc9534eb5d93dcb8bb567def37d42b8dcabcea426 (patch)
treeeeb54ec48954be6040e824880145b7909a51dc4a /libgrust
parentd9473a5b55d512658b826129ef8bed57fe7d0d73 (diff)
downloadgcc-c9534eb5d93dcb8bb567def37d42b8dcabcea426.zip
gcc-c9534eb5d93dcb8bb567def37d42b8dcabcea426.tar.gz
gcc-c9534eb5d93dcb8bb567def37d42b8dcabcea426.tar.bz2
gccrs: libproc_macro: Add drop function on Ident struct
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>
Diffstat (limited to 'libgrust')
-rw-r--r--libgrust/libproc_macro/ident.cc9
-rw-r--r--libgrust/libproc_macro/ident.h2
2 files changed, 10 insertions, 1 deletions
diff --git a/libgrust/libproc_macro/ident.cc b/libgrust/libproc_macro/ident.cc
index d7d5889..0bed2a8 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 5a2a46a..0e21275 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" {