close
end_reached = true
end
- enlarge(_buffer_capacity + read.length)
+ enlarge(_buffer_length + read.length)
read.copy_to_native(_buffer, read.length, 0, 0)
_buffer_length = read.length
end
fun enlarge(len: Int) do
if _buffer_capacity >= len then return
- while _buffer_capacity < len do _buffer_capacity *= 2
+ while _buffer_capacity < len do _buffer_capacity = _buffer_capacity * 2 + 2
var ns = new NativeString(_buffer_capacity)
_buffer.copy_to(ns, _buffer_length - _buffer_pos, _buffer_pos, 0)
_buffer = ns
return write(*self, &byt, 1);
`}
- fun read: String import NativeString.to_s_with_length, NativeString.to_s_with_copy `{
- static char c[1024];
+ fun read: String import NativeString.to_s_with_length, NativeString `{
+ char *c = new_NativeString(1024);
int n = read(*self, c, 1023);
if(n < 0) {
return NativeString_to_s_with_length("",0);
}
c[n] = 0;
- return NativeString_to_s_with_copy(c);
+ return NativeString_to_s_with_length(c, n);
`}
# Sets an option for the socket