Factor out make_istr utility function in runtime. Issue #855
This commit is contained in:
@@ -66,14 +66,9 @@ command_line_args : public kernel_owned<command_line_args>
|
|||||||
"command line arg interior");
|
"command line arg interior");
|
||||||
args_istr->fill = args_istr->alloc = sizeof(rust_vec*) * argc;
|
args_istr->fill = args_istr->alloc = sizeof(rust_vec*) * argc;
|
||||||
for (int i = 0; i < argc; ++i) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
size_t str_fill = strlen(argv[i]) + 1;
|
rust_vec *str = make_istr(kernel, argv[i],
|
||||||
size_t str_alloc = str_fill;
|
strlen(argv[i]),
|
||||||
rust_vec *str = (rust_vec *)
|
|
||||||
kernel->malloc(vec_size<char>(str_fill),
|
|
||||||
"command line arg");
|
"command line arg");
|
||||||
str->fill = str_fill;
|
|
||||||
str->alloc = str_alloc;
|
|
||||||
memcpy(&str->data, argv[i], str_fill);
|
|
||||||
((rust_vec**)&args_istr->data)[i] = str;
|
((rust_vec**)&args_istr->data)[i] = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,6 +218,19 @@ inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline rust_vec *
|
||||||
|
make_istr(rust_kernel* kernel, char* c, size_t strlen, const char* name) {
|
||||||
|
size_t str_fill = strlen + 1;
|
||||||
|
size_t str_alloc = str_fill;
|
||||||
|
rust_vec *str = (rust_vec *)
|
||||||
|
kernel->malloc(vec_size<char>(str_fill), name);
|
||||||
|
str->fill = str_fill;
|
||||||
|
str->alloc = str_alloc;
|
||||||
|
memcpy(&str->data, c, strlen);
|
||||||
|
str->data[strlen] = '\0';
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: C++
|
// mode: C++
|
||||||
|
|||||||
Reference in New Issue
Block a user