diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-04-12 17:47:43 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-04-21 13:15:47 +0000 |
commit | bf75c15d4057ae001becb94b16e4c79b0712db05 (patch) | |
tree | c7a5e79f3e6d116d8b60dc77848fc59c27c51ba3 | |
parent | 4984dd59b6b7f811ea81d69bfa24ff73c1d19ebf (diff) | |
download | gcc-bf75c15d4057ae001becb94b16e4c79b0712db05.zip gcc-bf75c15d4057ae001becb94b16e4c79b0712db05.tar.gz gcc-bf75c15d4057ae001becb94b16e4c79b0712db05.tar.bz2 |
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>
-rw-r--r-- | libgrust/libproc_macro/ident.cc | 9 | ||||
-rw-r--r-- | libgrust/libproc_macro/ident.h | 2 |
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" { |