diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-fmt.cc | 4 | ||||
-rw-r--r-- | gcc/rust/ast/rust-fmt.h | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-fmt.cc b/gcc/rust/ast/rust-fmt.cc index a7c4341..f6ee8a2 100644 --- a/gcc/rust/ast/rust-fmt.cc +++ b/gcc/rust/ast/rust-fmt.cc @@ -34,8 +34,10 @@ Pieces::collect (const std::string &to_parse) // auto pieces = std::vector<Piece> (piece_slice.base_ptr, // piece_slice.base_ptr + piece_slice.len); - return Pieces{}; + return Pieces (piece_slice); } +Pieces::~Pieces () { destroy_pieces (slice); } + } // namespace Fmt } // namespace Rust diff --git a/gcc/rust/ast/rust-fmt.h b/gcc/rust/ast/rust-fmt.h index 7ec9a2a..50aeff6 100644 --- a/gcc/rust/ast/rust-fmt.h +++ b/gcc/rust/ast/rust-fmt.h @@ -237,6 +237,7 @@ struct PieceSlice { const Piece *base_ptr; size_t len; + size_t cap; }; extern "C" { @@ -244,11 +245,19 @@ extern "C" { PieceSlice collect_pieces (const char *input); +void destroy_pieces (PieceSlice); + } // extern "C" struct Pieces { static Pieces collect (const std::string &to_parse); + ~Pieces (); + +private: + Pieces (PieceSlice slice) : slice (slice) {} + + PieceSlice slice; }; } // namespace Fmt |