Skip to content

Commit 21b9aef

Browse files
committed
protocol: cleanup unused code
1 parent 480da6d commit 21b9aef

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/protocol.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,7 @@ int callback_tty(struct lws *wsi, enum lws_callback_reasons reason, void *user,
258258
switch (command) {
259259
case INPUT:
260260
if (server->readonly) break;
261-
262-
char *data = xmalloc(pss->len - 1);
263-
memcpy(data, pss->buffer + 1, pss->len - 1);
264-
265-
uv_write_t *req = xmalloc(sizeof(uv_write_t));
266-
req->data = data;
267-
268-
int err = pty_write(pss->process, pty_buf_init(data, pss->len - 1));
261+
int err = pty_write(pss->process, pty_buf_init(pss->buffer + 1, pss->len - 1));
269262
if (err) {
270263
lwsl_err("uv_write: %s (%s)\n", uv_err_name(err), uv_strerror(err));
271264
return -1;

src/pty.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ void pty_resume(pty_process *process) {
136136
}
137137

138138
int pty_write(pty_process *process, pty_buf_t *buf) {
139-
if (process == NULL) return UV_ESRCH;
139+
if (process == NULL) {
140+
pty_buf_free(buf);
141+
return UV_ESRCH;
142+
}
140143
pty_io_t *io = process->io;
141144
uv_buf_t b = uv_buf_init(buf->base, buf->len);
142145
uv_write_t *req = xmalloc(sizeof(uv_write_t));

0 commit comments

Comments
 (0)