Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs24-19fa
git_rec_nano
Commits
45d2458b
Commit
45d2458b
authored
7 years ago
by
Benno Schulenberg
Browse files
Options
Download
Email Patches
Plain Diff
tweaks: don't bother freeing the key buffer, just reallocate it
parent
4c505e51
master
feature/match-parens
refactor/readbility
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/winio.c
+6
-12
src/winio.c
with
6 additions
and
12 deletions
+6
-12
src/winio.c
View file @
45d2458b
...
...
@@ -35,8 +35,7 @@
#endif
static
int
*
key_buffer
=
NULL
;
/* The keystroke buffer, containing all the keystrokes we
* haven't handled yet at a given point. */
/* A buffer for the keystrokes that haven't been handled yet. */
static
size_t
key_buffer_len
=
0
;
/* The length of the keystroke buffer. */
static
bool
solitary
=
FALSE
;
...
...
@@ -106,8 +105,7 @@ void run_macro(void)
return
;
}
free
(
key_buffer
);
key_buffer
=
(
int
*
)
nmalloc
(
macro_length
*
sizeof
(
int
));
key_buffer
=
(
int
*
)
nrealloc
(
key_buffer
,
macro_length
*
sizeof
(
int
));
key_buffer_len
=
macro_length
;
for
(
i
=
0
;
i
<
macro_length
;
i
++
)
...
...
@@ -210,9 +208,9 @@ void read_keys_from(WINDOW *win)
curs_set
(
0
);
/* Initiate the keystroke buffer, and save the keycode in it. */
key_buffer_len
++
;
key_buffer
=
(
int
*
)
nmalloc
(
sizeof
(
int
));
key_buffer
=
(
int
*
)
nrealloc
(
key_buffer
,
sizeof
(
int
));
key_buffer
[
0
]
=
input
;
key_buffer_len
=
1
;
#ifndef NANO_TINY
/* If we got a SIGWINCH, get out as the win argument is no longer valid. */
...
...
@@ -319,12 +317,8 @@ int *get_input(WINDOW *win, size_t input_len)
memcpy
(
input
,
key_buffer
,
input_len
*
sizeof
(
int
));
key_buffer_len
-=
input_len
;
/* If the keystroke buffer is now empty, mark it as such. */
if
(
key_buffer_len
==
0
)
{
free
(
key_buffer
);
key_buffer
=
NULL
;
}
else
{
/* Trim from the buffer the codes that were copied. */
/* If the buffer still contains keystrokes, move them to the front. */
if
(
key_buffer_len
>
0
)
{
memmove
(
key_buffer
,
key_buffer
+
input_len
,
key_buffer_len
*
sizeof
(
int
));
key_buffer
=
(
int
*
)
nrealloc
(
key_buffer
,
key_buffer_len
*
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help