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>
This commit is contained in:
Pierre-Emmanuel Patry
2023-04-12 17:47:43 +02:00
committed by Arthur Cohen
parent d9473a5b55
commit c9534eb5d9
2 changed files with 10 additions and 1 deletions

View 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

View 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" {