Allocate only as much as necessary.

This commit is contained in:
Ms2ger 2015-04-07 17:55:49 +02:00
parent cba3b6806e
commit 1fa1950ab1

View file

@ -246,7 +246,7 @@ impl<'a> CefWrap<cef_string_userfree_t> for String {
let boxed_string;
unsafe {
let buffer = libc::malloc((mem::size_of::<c_ushort>() as u64) *
((utf16_chars.len() + 1) as u64 + 1)) as *mut u16;
((utf16_chars.len() + 1) as u64)) as *mut u16;
for (i, ch) in utf16_chars.iter().enumerate() {
*buffer.offset(i as int) = *ch
}