Windows big copy

master
Allen Webster 2017-11-27 11:58:54 -05:00
parent e8e314efb2
commit c7b6948195
1 changed files with 8 additions and 1 deletions

View File

@ -341,10 +341,17 @@ win32_read_clipboard_contents(){
u32 clip_16_len = 0; u32 clip_16_len = 0;
for(;clip_16[clip_16_len];++clip_16_len); for(;clip_16[clip_16_len];++clip_16_len);
// TODO(allen): Extend the buffer if it is too small.
b32 error = false; b32 error = false;
u32 clip_8_len = (u32)utf16_to_utf8_minimal_checking(win32vars.clip_buffer, win32vars.clip_max-1, clip_16, clip_16_len, &error); u32 clip_8_len = (u32)utf16_to_utf8_minimal_checking(win32vars.clip_buffer, win32vars.clip_max-1, clip_16, clip_16_len, &error);
for (;clip_8_len >= win32vars.clip_max && !error;){
system_memory_free(win32vars.clip_buffer, win32vars.clip_max);
win32vars.clip_max = l_round_up_u32(clip_8_len, KB(4));
win32vars.clip_buffer = (u8*)system_memory_allocate(win32vars.clip_max);
clip_8_len = (u32)utf16_to_utf8_minimal_checking(win32vars.clip_buffer, win32vars.clip_max - 1, clip_16, clip_16_len, &error);
}
if (clip_8_len < win32vars.clip_max && !error){ if (clip_8_len < win32vars.clip_max && !error){
win32vars.clip_buffer[clip_8_len] = 0; win32vars.clip_buffer[clip_8_len] = 0;