Skip to content

Commit 7b62ec8

Browse files
committed
Remove strdup in wasi_nn_parse
1 parent a85079a commit 7b62ec8

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

product-mini/platforms/common/libc_wasi.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,12 @@ wasi_nn_parse(char **argv, wasi_nn_parse_context_t *ctx)
222222
goto fail;
223223
}
224224

225-
ctx->model_names[ctx->n_graphs] = strdup(tokens[0]);
226-
ctx->encoding[ctx->n_graphs] = strdup(tokens[1]);
227-
ctx->target[ctx->n_graphs] = strdup(tokens[2]);
228-
ctx->graph_paths[ctx->n_graphs++] = strdup(tokens[3]);
225+
ctx->model_names[ctx->n_graphs] = tokens[0];
226+
ctx->encoding[ctx->n_graphs] = tokens[1];
227+
ctx->target[ctx->n_graphs] = tokens[2];
228+
ctx->graph_paths[ctx->n_graphs++] = tokens[3];
229229

230230
fail:
231-
if (token)
232-
free(token);
233231

234232
return ret;
235233
}
@@ -243,16 +241,5 @@ wasi_nn_set_init_args(struct InstantiationArgs2 *args,
243241
ctx->encoding, ctx->target, ctx->n_graphs,
244242
ctx->graph_paths);
245243
wasm_runtime_instantiation_args_set_wasi_nn_registry(args, nn_registry);
246-
247-
for (uint32_t i = 0; i < ctx->n_graphs; i++) {
248-
if (ctx->model_names[i])
249-
free(ctx->model_names[i]);
250-
if (ctx->graph_paths[i])
251-
free(ctx->graph_paths[i]);
252-
if (ctx->encoding[i])
253-
free(ctx->encoding[i]);
254-
if (ctx->target[i])
255-
free(ctx->target[i]);
256-
}
257244
}
258245
#endif

0 commit comments

Comments
 (0)