From: Pierre-Emmanuel Patry Date: Wed, 12 Apr 2023 15:47:43 +0000 (+0200) Subject: gccrs: libproc_macro: Add drop function on Ident struct X-Git-Tag: basepoints/gcc-15~2633 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c9534eb5d93dcb8bb567def37d42b8dcabcea426;p=thirdparty%2Fgcc.git 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 --- diff --git a/libgrust/libproc_macro/ident.cc b/libgrust/libproc_macro/ident.cc index d7d588975d75..0bed2a8e7d4d 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 5a2a46a8c1f7..0e21275863ea 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" {