mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Fix issue with pasting text into console
This commit is contained in:
parent
4f5d5a6813
commit
ed316491ca
1 changed files with 17 additions and 6 deletions
|
@ -30,6 +30,7 @@
|
|||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/intrin/weaken.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/nt/console.h"
|
||||
#include "libc/nt/enum/filetype.h"
|
||||
#include "libc/nt/enum/vk.h"
|
||||
|
@ -319,14 +320,24 @@ static textwindows struct Keystroke *NewKeystroke(void) {
|
|||
if (atomic_load_explicit(&__keystroke.allocated, memory_order_acquire) < n &&
|
||||
(i = atomic_fetch_add(&__keystroke.allocated, 1)) < n) {
|
||||
k = __keystroke.pool + i;
|
||||
} else if ((e = dll_first(__keystroke.free))) {
|
||||
k = KEYSTROKE_CONTAINER(e);
|
||||
dll_remove(&__keystroke.free, &k->elem);
|
||||
} else {
|
||||
return 0;
|
||||
if ((e = dll_first(__keystroke.free))) {
|
||||
k = KEYSTROKE_CONTAINER(e);
|
||||
dll_remove(&__keystroke.free, &k->elem);
|
||||
}
|
||||
if (!k) {
|
||||
if (_weaken(malloc)) {
|
||||
k = _weaken(malloc)(sizeof(struct Keystroke));
|
||||
} else {
|
||||
enomem();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k) {
|
||||
bzero(k, sizeof(*k));
|
||||
dll_init(&k->elem);
|
||||
}
|
||||
bzero(k, sizeof(*k));
|
||||
dll_init(&k->elem);
|
||||
return k;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue