[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/11] glr2.cc: fix memory leak
From: |
Akim Demaille |
Subject: |
[PATCH 05/11] glr2.cc: fix memory leak |
Date: |
Sun, 10 Jan 2021 17:59:04 +0100 |
* data/skeletons/glr2.cc (glr_stack_item::setState): Free the previous
state before installing the new one.
---
data/skeletons/glr2.cc | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/data/skeletons/glr2.cc b/data/skeletons/glr2.cc
index 77c64641..19773cd2 100644
--- a/data/skeletons/glr2.cc
+++ b/data/skeletons/glr2.cc
@@ -1374,10 +1374,10 @@ public:
~glr_stack_item ()
{]b4_parse_assert_if([[
check_ ();]])[
- if (is_state())
- getState().~glr_state();
+ if (is_state ())
+ getState ().~glr_state ();
else
- getOption().~semantic_option();
+ getOption ().~semantic_option ();
}
void setState (const glr_state &state)
@@ -1386,12 +1386,12 @@ public:
state.check_ ();]])[
if (this != state.asItem ())
{
- is_state_ = true;
- // FIXME: What about the previous content? Shouldn't it be
- // freed? It might be useful to have an explicit "void" state
- // when this item is in unused state (in the list of free
- // items), when parse.assert is set.
+ if (is_state_)
+ getState ().~glr_state ();
+ else
+ getOption ().~semantic_option ();
new (&raw_) glr_state (state);
+ is_state_ = true;
}
}
--
2.30.0
- [PATCH 00/11] glr2.cc: add support for token constructors, Akim Demaille, 2021/01/10
- [PATCH 01/11] tests: fix definition for parser class name, Akim Demaille, 2021/01/10
- [PATCH 02/11] glr: tests: formatting changes, Akim Demaille, 2021/01/10
- [PATCH 03/11] glr: tests: more macros, Akim Demaille, 2021/01/10
- [PATCH 04/11] glr: examples: fix locations, Akim Demaille, 2021/01/10
- [PATCH 05/11] glr2.cc: fix memory leak,
Akim Demaille <=
- [PATCH 06/11] glr2.cc: use references to print symbols, Akim Demaille, 2021/01/10
- [PATCH 07/11] glr2.cc: example: style changes, Akim Demaille, 2021/01/10
- [PATCH 08/11] glr2.cc: rely on symbol kinds rather than token kinds, Akim Demaille, 2021/01/10
- [PATCH 09/11] glr2.cc: tests: simplify, Akim Demaille, 2021/01/10
- [PATCH 11/11] glr2.cc: add support for api.token.constructor, Akim Demaille, 2021/01/10
- [PATCH 10/11] glr2.cc: introduce the yytranslate_ member function, Akim Demaille, 2021/01/10