- val[txt.bytelen] = 0u8
- txt.to_cstring.copy_to(val, txt.bytelen, 0, 0)
+ val[txt.byte_length] = 0
+ txt.to_cstring.copy_to(val, txt.byte_length, 0, 0)
+
+ return instance
+ end
+
+ # Return a new C string initialized with `txt`
+ fun c_string_instance_from_ns(txt: CString, len: Int): Instance
+ do
+ var instance = c_string_instance_len(len)
+ var val = instance.val
+ txt.copy_to(val, len, 0, 0)
+
+ return instance
+ end
+
+ # Return a new C string instance sharing the same data space as `txt`
+ fun c_string_instance_fast_cstr(txt: CString, from: Int): Instance
+ do
+ var ncstr = txt.fast_cstring(from)
+ var t = mainmodule.c_string_type
+
+ var instance = new PrimitiveInstance[CString](t, ncstr)
+ init_instance_primitive(instance)