Skip to content

Commit ab4679a

Browse files
committed
---
yaml --- r: 5119 b: refs/heads/master c: 372aa4d h: refs/heads/master i: 5117: b367ecf 5115: 627f9ce 5111: 9c1f35f 5103: f971929 5087: 289d39d 5055: 749fb47 4991: 6bd25f7 4863: 9cf28fa 4607: 90c3a45 4095: 1cb4a68 v: v3
1 parent d46c765 commit ab4679a

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3690f38d798b2a0009af9c18ba034f7a2411390e
2+
refs/heads/master: 372aa4d2107ddaa5de98a0f71e66ffd9d0f59562

trunk/src/rt/rust.cpp

+3-8
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,9 @@ command_line_args : public kernel_owned<command_line_args>
6666
"command line arg interior");
6767
args_istr->fill = args_istr->alloc = sizeof(rust_vec*) * argc;
6868
for (int i = 0; i < argc; ++i) {
69-
size_t str_fill = strlen(argv[i]) + 1;
70-
size_t str_alloc = str_fill;
71-
rust_vec *str = (rust_vec *)
72-
kernel->malloc(vec_size<char>(str_fill),
73-
"command line arg");
74-
str->fill = str_fill;
75-
str->alloc = str_alloc;
76-
memcpy(&str->data, argv[i], str_fill);
69+
rust_vec *str = make_istr(kernel, argv[i],
70+
strlen(argv[i]),
71+
"command line arg");
7772
((rust_vec**)&args_istr->data)[i] = str;
7873
}
7974
}

trunk/src/rt/rust_util.h

+13
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
218218
}
219219
}
220220

221+
inline rust_vec *
222+
make_istr(rust_kernel* kernel, char* c, size_t strlen, const char* name) {
223+
size_t str_fill = strlen + 1;
224+
size_t str_alloc = str_fill;
225+
rust_vec *str = (rust_vec *)
226+
kernel->malloc(vec_size<char>(str_fill), name);
227+
str->fill = str_fill;
228+
str->alloc = str_alloc;
229+
memcpy(&str->data, c, strlen);
230+
str->data[strlen] = '\0';
231+
return str;
232+
}
233+
221234
//
222235
// Local Variables:
223236
// mode: C++

0 commit comments

Comments
 (0)