Skip to content

Commit 6e7f0da

Browse files
authored
Merge pull request #47 from lightpanda-io/deinit_inspector_session
+ add missing delete function for inspector session Inspector.Connect(..) returns a unique_ptr from the C++ side so we need to take care to at least be able to clean it up. In the future we may want the Inspector to "own" all sessions. For now the user is required to deinit the session.
2 parents ac2f707 + 44ee842 commit 6e7f0da

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/binding.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ v8::Platform* v8__Platform__NewDefaultPlatform(
104104
int thread_pool_size,
105105
bool idle_task_support) {
106106
return v8::platform::NewDefaultPlatform(
107-
thread_pool_size,
107+
thread_pool_size,
108108
idle_task_support ? v8::platform::IdleTaskSupport::kEnabled : v8::platform::IdleTaskSupport::kDisabled,
109109
v8::platform::InProcessStackDumping::kDisabled,
110110
nullptr
@@ -1614,6 +1614,10 @@ void v8_inspector__Inspector__ContextCreated(v8_inspector::V8Inspector *self,
16141614

16151615
// InspectorSession
16161616

1617+
void v8_inspector__Session__DELETE(v8_inspector::V8InspectorSession* self) {
1618+
delete self;
1619+
}
1620+
16171621
void v8_inspector__Session__dispatchProtocolMessage(
16181622
v8_inspector::V8InspectorSession *session, v8::Isolate *isolate,
16191623
const char *msg, int msg_len) {

src/binding.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ bool v8__TryCatch__HasCaught(const TryCatch* self);
298298
const Value* v8__TryCatch__StackTrace(const TryCatch* self, const Context* context);
299299
bool v8__TryCatch__IsVerbose(const TryCatch* self);
300300
void v8__TryCatch__SetVerbose(
301-
TryCatch* self,
301+
TryCatch* self,
302302
bool value);
303303
const Value* v8__TryCatch__ReThrow(TryCatch* self);
304304

@@ -568,7 +568,7 @@ int64_t v8__Integer__Value(const Integer* self);
568568

569569
// BigInt
570570
const BigInt* v8__BigInt__New(
571-
Isolate* iso,
571+
Isolate* iso,
572572
int64_t val);
573573
const BigInt* v8__BigInt__NewFromUnsigned(
574574
Isolate* iso,
@@ -697,7 +697,7 @@ void v8__Function__SetName(const Function* self, const String* name);
697697

698698
// External
699699
const External* v8__External__New(
700-
Isolate* isolate,
700+
Isolate* isolate,
701701
void* value);
702702
void* v8__External__Value(
703703
const External* self);
@@ -996,6 +996,7 @@ const Context* v8_inspector__Client__IMPL__descriptionForValueSubtype(
996996
// InspectorSession
997997

998998
typedef struct InspectorSession InspectorSession;
999+
void v8_inspector__Session__DELETE(Inspector *self);
9991000
void v8_inspector__Session__dispatchProtocolMessage(InspectorSession *session, Isolate *isolate, const char* msg, usize msg_len);
10001001

10011002
// Inspector

src/v8.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,10 @@ pub export fn v8_inspector__Channel__IMPL__flushProtocolNotifications(
26532653
pub const InspectorSession = struct {
26542654
handle: *c.InspectorSession,
26552655

2656+
pub fn deinit(self: InspectorSession) void {
2657+
c.v8_inspector__Session__DELETE(self.handle);
2658+
}
2659+
26562660
pub fn dispatchProtocolMessage(
26572661
self: InspectorSession,
26582662
isolate: Isolate,

0 commit comments

Comments
 (0)