extra: stop rl from leaking each line that is read.
This commit is contained in:
parent
21ce41d42d
commit
fe03d827a4
@ -91,7 +91,17 @@ pub fn read(prompt: &str) -> Option<~str> {
|
||||
let line = locked!(rustrt::linenoise(buf));
|
||||
|
||||
if line.is_null() { None }
|
||||
else { Some(str::raw::from_c_str(line)) }
|
||||
else {
|
||||
unsafe {
|
||||
do (|| {
|
||||
Some(str::raw::from_c_str(line))
|
||||
}).finally {
|
||||
// linenoise's return value is from strdup, so we
|
||||
// better not leak it.
|
||||
rt::global_heap::exchange_free(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user