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>
void
Ident__drop (Ident *ident)
{
- delete[] ident->val;
+ Ident::drop (ident);
}
Ident
return {raw, val, len};
}
+void
+Ident::drop (Ident *ident)
+{
+ delete[] ident->val;
+ ident->len = 0;
+}
+
} // namespace Ident
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" {