rm dupavlue and freevalue

This commit is contained in:
2026-02-25 09:41:27 -06:00
parent 3d87fdeb5f
commit 20376aa5e4
8 changed files with 34 additions and 109 deletions

View File

@@ -42,8 +42,6 @@ static inline ImVec2 js2imvec2(JSContext *js, JSValue v)
JSValue y = JS_GetPropertyNumber(js, v, 1);
JS_ToFloat64(js, &dx, x);
JS_ToFloat64(js, &dy, y);
JS_FreeValue(js, x);
JS_FreeValue(js, y);
c.x = dx;
c.y = dy;
return c;
@@ -61,10 +59,7 @@ static inline ImVec4 js2imvec4(JSContext *js, JSValue v)
JS_ToFloat64(js, &dy, y);
JS_ToFloat64(js, &dz, z);
JS_ToFloat64(js, &dw, w);
JS_FreeValue(js, x);
JS_FreeValue(js, y);
JS_FreeValue(js, z);
JS_FreeValue(js, w);
c.x = dx;
c.y = dy;
c.z = dz;
@@ -142,7 +137,7 @@ JSC_SSCALL(imgui_textinput,
if (strcmp(buffer, str2))
ret = JS_NewString(js,buffer);
else
ret = JS_DupValue(js,argv[1]);
ret = argv[1];
)
JSC_SSCALL(imgui_textbox,
@@ -156,7 +151,7 @@ JSC_SSCALL(imgui_textbox,
if (strcmp(buffer, str2))
ret = JS_NewString(js,buffer);
else
ret = JS_DupValue(js,argv[1]);
ret = argv[1];
)
JSC_SCALL(imgui_combo,
@@ -181,7 +176,6 @@ JSC_SCALL(imgui_combo,
for (int i = 0; i < item_count; i++) {
JSValue item = JS_GetPropertyNumber(js, argv[2], i);
items[i] = JS_ToCString(js, item);
JS_FreeValue(js, item);
}
// If preview_str is set, find its index
@@ -198,7 +192,7 @@ JSC_SCALL(imgui_combo,
ret = JS_NewString(js, items[current_item]);
} else {
if (preview_str) {
ret = JS_DupValue(js, argv[1]);
ret = argv[1];
} else {
ret = JS_NewString(js, items[current_item]);
}
@@ -222,12 +216,12 @@ JSC_SCALL(imgui_combo,
}
ret = JS_NewString(js, p);
} else {
ret = JS_DupValue(js, argv[1]);
ret = argv[1];
}
JS_FreeCString(js, items_str);
} else {
ret = JS_DupValue(js, argv[1]);
ret = argv[1];
}
if (preview_str) {
@@ -258,7 +252,6 @@ JSC_SCALL(imgui_slider,
double d;
JS_ToFloat64(js, &d, val);
a[i] = (float)d;
JS_FreeValue(js, val);
}
switch(n) {
@@ -299,7 +292,6 @@ JSC_SCALL(imgui_intslider,
double d;
JS_ToFloat64(js, &d, val);
a[i] = (int)d;
JS_FreeValue(js, val);
}
switch(n) {
@@ -451,8 +443,6 @@ JSC_SCALL(imgui_table,
send[0] = JS_NewInt32(js,spec->ColumnIndex);
send[1] = JS_NewBool(js,spec->SortDirection == ImGuiSortDirection_Ascending);
JS_Call(js, argv[3], JS_NULL, 2, send);
JS_FreeValue(js, send[0]);
JS_FreeValue(js, send[1]);
}
sort_specs->SpecsDirty = false;
}
@@ -795,11 +785,10 @@ JSC_CCALL(imgui_axisfmt,
int y = num_to_yaxis(js2number(js, argv[0]));
if (!JS_IsNull(axis_fmts[y])) {
JS_FreeValue(js, axis_fmts[y]);
axis_fmts[y] = JS_NULL;
}
axis_fmts[y] = JS_DupValue(js,argv[1]);
axis_fmts[y] = argv[1];
ImPlot::SetupAxisFormat(y, (ImPlotFormatter)jsformatter, (void*)(axis_fmts+y));
)
@@ -832,7 +821,6 @@ JSC_CCALL(imgui_startnode,
ab[1] = JS_NewInt32(js,end_attr);
JS_Call(js,argv[1], JS_NULL, 2, ab);
for (int i = 0; i < 2; i++) JS_FreeValue(js, ab[i]);
}
int node_id;
@@ -840,7 +828,6 @@ JSC_CCALL(imgui_startnode,
{
JSValue a = JS_NewInt32(js,node_id);
JS_Call(js, argv[2], JS_NULL, 1,&a);
JS_FreeValue(js,a);
}
int link_id;
@@ -848,7 +835,6 @@ JSC_CCALL(imgui_startnode,
{
JSValue a = JS_NewInt32(js,link_id);
JS_Call(js, argv[3], JS_NULL, 1,&a);
JS_FreeValue(js,a);
}
)