Skip to content

Commit 0510c71

Browse files
committed
Revert "Move reserved handle check to C++ too"
This reverts commit e15a9f7.
1 parent 81fdb3c commit 0510c71

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/embind/emval.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ var LibraryEmVal = {
8080

8181
_emval_free__deps: ['$emval_handles'],
8282
_emval_free: (handle) => {
83-
emval_handles.free(handle);
83+
if (handle >= emval_handles.reserved) {
84+
emval_handles.free(handle);
85+
}
8486
},
8587

8688
_emval_run_destructors__deps: ['_emval_free', '$Emval', '$runDestructors'],

system/include/emscripten/val.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ void _emval_register_symbol(const char*);
3838

3939
enum {
4040
_EMVAL_UNDEFINED = 1,
41-
_EMVAL_NULL,
42-
_EMVAL_TRUE,
43-
_EMVAL_FALSE,
44-
_EMVAL_UNRESERVED_START
41+
_EMVAL_NULL = 2,
42+
_EMVAL_TRUE = 3,
43+
_EMVAL_FALSE = 4
4544
};
4645

4746
typedef struct _EM_DESTRUCTORS* EM_DESTRUCTORS;
@@ -340,9 +339,7 @@ struct val_metadata {
340339

341340
// should be only accessible from dec_ref
342341
~val_metadata() {
343-
if (handle >= EM_VAL(internal::_EMVAL_UNRESERVED_START)) {
344-
internal::_emval_free(handle);
345-
}
342+
_emval_free(handle);
346343
}
347344
};
348345

0 commit comments

Comments
 (0)