mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Add a rust_str typedef to the runtime. Issue #855
This commit is contained in:
parent
01b254b411
commit
1b67d211b4
@ -43,10 +43,10 @@ command_line_args : public kernel_owned<command_line_args>
|
||||
"command line arg interior");
|
||||
args->fill = args->alloc = sizeof(rust_vec*) * argc;
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
rust_vec *str = make_str(kernel, argv[i],
|
||||
rust_str *str = make_str(kernel, argv[i],
|
||||
strlen(argv[i]),
|
||||
"command line arg");
|
||||
((rust_vec**)&args->data)[i] = str;
|
||||
((rust_str**)&args->data)[i] = str;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
/* Native builtins. */
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
extern "C" CDECL rust_str*
|
||||
last_os_error(rust_task *task) {
|
||||
LOG(task, task, "last_os_error()");
|
||||
|
||||
@ -40,15 +40,15 @@ last_os_error(rust_task *task) {
|
||||
}
|
||||
#endif
|
||||
|
||||
rust_vec * st = make_str(task->kernel, buf, strlen(buf),
|
||||
"last_os_error");
|
||||
rust_str * st = make_str(task->kernel, buf, strlen(buf),
|
||||
"last_os_error");
|
||||
#ifdef __WIN32__
|
||||
LocalFree((HLOCAL)buf);
|
||||
#endif
|
||||
return st;
|
||||
}
|
||||
|
||||
extern "C" CDECL rust_vec *
|
||||
extern "C" CDECL rust_str *
|
||||
rust_getcwd(rust_task *task) {
|
||||
LOG(task, task, "rust_getcwd()");
|
||||
|
||||
@ -323,15 +323,15 @@ debug_ptrcast(rust_task *task,
|
||||
|
||||
extern "C" CDECL rust_vec*
|
||||
rust_list_files(rust_task *task, rust_vec **path) {
|
||||
array_list<rust_vec*> strings;
|
||||
array_list<rust_str*> strings;
|
||||
#if defined(__WIN32__)
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind = FindFirstFile((char*)(*path)->data, &FindFileData);
|
||||
if (hFind != INVALID_HANDLE_VALUE) {
|
||||
do {
|
||||
rust_vec *str = make_str(task->kernel, FindFileData.cFileName,
|
||||
strlen(FindFileData.cFileName),
|
||||
"list_files_str");
|
||||
rust_str *str = make_str(task->kernel, FindFileData.cFileName,
|
||||
strlen(FindFileData.cFileName),
|
||||
"list_files_str");
|
||||
strings.push(str);
|
||||
} while (FindNextFile(hFind, &FindFileData));
|
||||
FindClose(hFind);
|
||||
|
@ -188,11 +188,13 @@ inline void reserve_vec(rust_task* task, rust_vec** vpp, size_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
inline rust_vec *
|
||||
typedef rust_vec rust_str;
|
||||
|
||||
inline rust_str *
|
||||
make_str(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 *)
|
||||
rust_str *str = (rust_str *)
|
||||
kernel->malloc(vec_size<char>(str_fill), name);
|
||||
str->fill = str_fill;
|
||||
str->alloc = str_alloc;
|
||||
|
Loading…
Reference in New Issue
Block a user