You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticvoidbindKey(key, Function handler) {
LibReadline.init();
var functionType =getBinaryType("rl_command_func_t");
var callback =newBinaryCallback(functionType, (args) {
if (handler isReadlineCommandRegularFunction) {
returnhandler(args[0], args[1]);
} else {
returnhandler();
}
});
checkSysCallResult(invoke("readline::rl_bind_key", [key isString? key.codeUnitAt(0) : key, callback.functionCode]));
}
After the last use (in checkSysCallResult) of the binary data (BinaryCallback) it will be freed by the garbage collector at the first opportunity.
Binary function code also would be invalid (deallocated).
I do not know how the "readline" works but if you want create a "long life" binary callback you should return it back and store it in a safe place.
Local variables not a good place.
If it used only in the function body then you can use method keepAlive()
var data =allocData();
someFunc(data);
// above we not use data directly// but some code may use data in physical memory// Without this data would be freed// Keep it alivekeepAlive(data);
The text was updated successfully, but these errors were encountered:
After the last use (in
checkSysCallResult
) of the binary data (BinaryCallback
) it will be freed by the garbage collector at the first opportunity.Binary function code also would be invalid (deallocated).
I do not know how the "readline" works but if you want create a "long life" binary callback you should return it back and store it in a safe place.
Local variables not a good place.
If it used only in the function body then you can use method
keepAlive()
The text was updated successfully, but these errors were encountered: