Skip to content

Commit

Permalink
Keep original readline buffer sizes
Browse files Browse the repository at this point in the history
When we create a Readline "context" object we heap allocate buffers that
libreadline requires. So far we have specified our own buffer sizes,
independent of libreadline's defaults. But there really is no good
reason not to go with whatever they were using from the get-go.
Thus, with this change we just allocate as many bytes as libreadline
would by default.
  • Loading branch information
d-e-s-o committed Apr 6, 2024
1 parent f58cc41 commit 59214ba
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib.rs
Expand Up @@ -250,10 +250,8 @@ impl Readline {
// allocated by libreadline itself, as part of its
// initialization. Because we create a new context we need to
// reinitialize this data.
rl_line_buffer = calloc(1, 64).cast();
rl_line_buffer_len = 64;
rl_executing_keyseq = calloc(1, 16).cast();
rl_key_sequence_length = 16;
rl_line_buffer = calloc(1, rl_line_buffer_len as _).cast();
rl_executing_keyseq = calloc(1, rl_key_sequence_length as _).cast();

// We use similar behavior to default Rust and panic on
// allocation failure.
Expand Down

0 comments on commit 59214ba

Please sign in to comment.