Factor out make_istr utility function in runtime. Issue #855
This commit is contained in:
parent
3690f38d79
commit
372aa4d210
2 changed files with 16 additions and 8 deletions
|
@ -66,14 +66,9 @@ command_line_args : public kernel_owned<command_line_args>
|
|||
"command line arg interior");
|
||||
args_istr->fill = args_istr->alloc = sizeof(rust_vec*) * argc;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
size_t str_fill = strlen(argv[i]) + 1;
|
||||
size_t str_alloc = str_fill;
|
||||
rust_vec *str = (rust_vec *)
|
||||
kernel->malloc(vec_size<char>(str_fill),
|
||||
"command line arg");
|
||||
str->fill = str_fill;
|
||||
str->alloc = str_alloc;
|
||||
memcpy(&str->data, argv[i], str_fill);
|
||||
rust_vec *str = make_istr(kernel, argv[i],
|
||||
strlen(argv[i]),
|
||||
"command line arg");
|
||||
((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:
|
||||
// mode: C++
|
||||
|
|
Loading…
Add table
Reference in a new issue