about summary refs log tree commit diff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorLindsey Kuper <lkuper@mozilla.com>2011-03-18 12:32:54 -0700
committerLindsey Kuper <lkuper@mozilla.com>2011-03-18 12:32:54 -0700
commit6dee1ac161a22a4bc1e49c5dac3c7bbba1ff97f0 (patch)
treef423d576e977e7a258f09e50e5a51702525782e2 /src/rt/rust_builtin.cpp
parent830f2d02f19b45ff4b4a4d7946b69f206b5dcdff (diff)
parent6f65ce5255ac16204490bdd7dcf99acd24876bc6 (diff)
downloadrust-6dee1ac161a22a4bc1e49c5dac3c7bbba1ff97f0.tar.gz
rust-6dee1ac161a22a4bc1e49c5dac3c7bbba1ff97f0.zip
Merge branch 'master' of git://github.com/graydon/rust
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index fcea449ddd9..1f17fc8c075 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -207,6 +207,29 @@ str_from_vec(rust_task *task, rust_vec *v)
     return st;
 }
 
+extern "C" CDECL rust_str *
+str_from_cstr(rust_task *task, char *sbuf)
+{
+    size_t len = strlen(sbuf) + 1;
+    rust_str *st = vec_alloc_with_data(task, len, len, 1, sbuf);
+    if (!st) {
+        task->fail(2);
+        return NULL;
+    }
+    return st;
+}
+
+extern "C" CDECL rust_str *
+str_from_buf(rust_task *task, char *buf, unsigned int len) {
+    rust_str *st = vec_alloc_with_data(task, len + 1, len, 1, buf);
+    if (!st) {
+        task->fail(2);
+        return NULL;
+    }
+    st->data[st->fill++] = '\0';
+    return st;
+}
+
 extern "C" CDECL void *
 rand_new(rust_task *task)
 {