Skip to content

Commit 5c31fc8

Browse files
fix: remove usage of platform dependent strlen (#21) (#22)
Fixes #21 and enables the extism java sdk to be used on windows. Signed-off-by: Thomas Darimont <[email protected]>
1 parent 91c1949 commit 5c31fc8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/main/java/org/extism/sdk/LibExtism.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,4 @@ Pointer extism_function_new(String name,
169169
Pointer extism_plugin_cancel_handle(Pointer pluginPointer);
170170
boolean extism_plugin_cancel(Pointer cancelHandle);
171171
void extism_function_set_namespace(Pointer p, String name);
172-
int strlen(Pointer s);
173172
}

src/main/java/org/extism/sdk/Plugin.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ public Plugin(byte[] manifestBytes, boolean withWASI, HostFunction[] functions)
4242
withWASI,
4343
errormsg);
4444
if (p == null) {
45-
if (functions != null)
45+
if (functions != null) {
4646
for (int i = 0; i < functions.length; i++) {
47-
LibExtism.INSTANCE.extism_function_free(functions[i].pointer);
47+
LibExtism.INSTANCE.extism_function_free(functions[i].pointer);
4848
}
49-
int errlen = LibExtism.INSTANCE.strlen(errormsg[0]);
50-
byte[] msg = new byte[errlen];
51-
errormsg[0].read(0, msg, 0, errlen);
49+
}
50+
String msg = errormsg[0].getString(0);
5251
LibExtism.INSTANCE.extism_plugin_new_error_free(errormsg[0]);
53-
throw new ExtismException(new String(msg));
52+
throw new ExtismException(msg);
5453
}
5554

5655
this.functions = functions;

0 commit comments

Comments
 (0)