mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-21 16:08:24 +03:00
Release compiled oniguruma regex in destructor of user data object
This commit is contained in:
parent
7682f586be
commit
58510c2cc4
@ -14,6 +14,10 @@ public:
|
||||
m_regex = [[OnigRegexp compile:sourceString] retain];
|
||||
}
|
||||
|
||||
~OnigRegexpUserData() {
|
||||
[m_regex release];
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> Search(CefRefPtr<CefV8Value> string, CefRefPtr<CefV8Value> index) {
|
||||
OnigResult *result = [m_regex search:stringFromCefV8Value(string) start:index->GetIntValue()];
|
||||
|
||||
@ -36,10 +40,8 @@ public:
|
||||
OnigRegexp *m_regex;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(OnigRegexpUserData);
|
||||
|
||||
};
|
||||
|
||||
|
||||
OnigRegexpExtension::OnigRegexpExtension() : CefV8Handler() {
|
||||
NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"src/stdlib/onig-reg-exp-extension.js"];
|
||||
NSString *extensionCode = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
|
||||
@ -51,7 +53,6 @@ bool OnigRegexpExtension::Execute(const CefString& name,
|
||||
const CefV8ValueList& arguments,
|
||||
CefRefPtr<CefV8Value>& retval,
|
||||
CefString& exception) {
|
||||
|
||||
if (name == "buildOnigRegExp") {
|
||||
CefRefPtr<CefBase> userData = new OnigRegexpUserData(arguments[0]);
|
||||
retval = CefV8Value::CreateObject(userData, NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user