Skip to content

Commit

Permalink
Avoid needless reallocation of host & port strings on iOS
Browse files Browse the repository at this point in the history
This is also extremely likely a memory leak since we're never cleaning
these up - best to avoid that!
  • Loading branch information
pimterry committed Jun 12, 2024
1 parent b038788 commit b96aac3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ios/ios-connect-hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ const nw_endpoint_create_host = new NativeFunction(
'pointer', ['pointer', 'pointer']
);

const newHostStr = Memory.allocUtf8String(PROXY_HOST);
const newPortStr = Memory.allocUtf8String(PROXY_PORT.toString());

Interceptor.attach(nw_connection_create, {
onEnter: function (args) {
const newHostStr = Memory.allocUtf8String(PROXY_HOST);
const newPortStr = Memory.allocUtf8String(PROXY_PORT.toString());

// Replace the endpoint argument entirely with our own:
args[0] = nw_endpoint_create_host(newHostStr, newPortStr);
}
Expand Down

0 comments on commit b96aac3

Please sign in to comment.