Skip to content

Commit

Permalink
Update xkcp_spy.c
Browse files Browse the repository at this point in the history
  • Loading branch information
liudf0716 authored Apr 18, 2017
1 parent 7c3571f commit 0c2ea68
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions xkcp_spy.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ static void readcb(struct bufferevent *bev, void *ctx)
{
struct event_base *base = ctx;
struct evbuffer *input = bufferevent_get_input(bev);
char buf[1024] = {0};
int len;

while ((len = evbuffer_remove(input, buf, sizeof(buf)-1)) > 0) {
printf("%s", buf);
memset(buf, 0, 1024);
}
printf("\n");
int len = evbuffer_get_length(input);

if (len > 0) {
char *buf = malloc(len+1);
memset(buf, 0, len+1);
evbuffer_remove(input, buf, len);
printf("%s\n", buf);
}

event_base_loopexit(base, NULL);
}
Expand Down

0 comments on commit 0c2ea68

Please sign in to comment.