Skip to content

Commit 986174b

Browse files
committed
Replace bh_* to generic solution
Signed-off-by: Krisztian Szilvasi <34309983+kr-t@users.noreply.github.com>
1 parent bdfd724 commit 986174b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/shared/platform/zephyr/zephyr_file.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "platform_api_vmcore.h"
77
#include "platform_api_extension.h"
88
#include "libc_errno.h"
9-
#include "bh_common.h"
109

1110
#include <string.h>
1211
#include <stdlib.h>
@@ -121,13 +120,15 @@ zephyr_fs_alloc_obj(bool is_dir, const char *path, int *index)
121120
ptr = &desc_array[i];
122121
ptr->used = true;
123122
ptr->is_dir = is_dir;
124-
ptr->path = bh_strdup(path);
125123
ptr->dir_index = 0;
124+
size_t path_len = strlen(path) + 1;
125+
ptr->path = BH_MALLOC(path_len);
126126
if (ptr->path == NULL) {
127127
ptr->used = false;
128128
k_mutex_unlock(&desc_array_mutex);
129129
return NULL;
130130
}
131+
strcpy(ptr->path, path);
131132
*index = i + 3;
132133
break;
133134
}
@@ -851,8 +852,10 @@ os_renameat(os_file_handle old_handle, const char *old_path,
851852
for (int i = 0; i < CONFIG_WASI_MAX_OPEN_FILES; i++) {
852853
struct zephyr_fs_desc *ptr = &desc_array[i];
853854
if (ptr->used && ptr->path && strcmp(ptr->path, abs_old_path) == 0) {
854-
char *new_path_copy = bh_strdup(new_path);
855+
size_t new_path_len = strlen(abs_new_path) + 1;
856+
char *new_path_copy = BH_MALLOC(new_path_len);
855857
if (new_path_copy != NULL) {
858+
strcpy(new_path_copy, abs_new_path);
856859
BH_FREE(ptr->path);
857860
ptr->path = new_path_copy;
858861
}

0 commit comments

Comments
 (0)