Fix memory leaks
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "io/knot.h"
|
||||
#include "io/sysio.h"
|
||||
#include "pch.h"
|
||||
#include "syntax/trie.h"
|
||||
|
||||
struct Highlight {
|
||||
@@ -40,9 +41,4 @@ struct LineData {
|
||||
std::shared_ptr<void> out_state{nullptr};
|
||||
};
|
||||
|
||||
struct CustomState {
|
||||
mrb_value state;
|
||||
CustomState(mrb_value s) : state(s) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef SYNTAX_LANGS_H
|
||||
#define SYNTAX_LANGS_H
|
||||
|
||||
#include "scripting/decl.h"
|
||||
#include "syntax/decl.h"
|
||||
|
||||
#define DEF_LANG(name) \
|
||||
@@ -15,6 +16,12 @@
|
||||
#name, { name##_parse, name##_state_match } \
|
||||
}
|
||||
|
||||
struct CustomState {
|
||||
mrb_value state;
|
||||
CustomState(mrb_value s) : state(s) { mrb_gc_register(mrb, state); }
|
||||
~CustomState() { mrb_gc_unregister(mrb, state); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline std::shared_ptr<T> ensure_state(std::shared_ptr<T> state) {
|
||||
using U = typename T::full_state_type;
|
||||
|
||||
Reference in New Issue
Block a user