Skip to content

Commit

Permalink
Do with one malloc call
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Sep 24, 2024
1 parent d22780e commit fb92648
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions hbjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,14 @@ function hbjs(Module) {
}

function version() {
var major = exports.malloc(4);
var minor = exports.malloc(4);
var micro = exports.malloc(4);
exports.hb_version(major, minor, micro);
var versionPtr = exports.malloc(12);
exports.hb_version(versionPtr, versionPtr + 4, versionPtr + 8);
var version = {
major: heapu32[major / 4],
minor: heapu32[minor / 4],
micro: heapu32[micro / 4],
major: heapu32[versionPtr / 4],
minor: heapu32[(versionPtr + 4) / 4],
micro: heapu32[(versionPtr + 8) / 4],
};
exports.free(major);
exports.free(minor);
exports.free(micro);
exports.free(versionPtr);
return version;
}

Expand Down

0 comments on commit fb92648

Please sign in to comment.