mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Make the evbuffer_readln backport follow the current API
This commit is contained in:
parent
b04cc60f13
commit
c545485407
7
buffer.c
7
buffer.c
@ -64,6 +64,7 @@
|
||||
#include "event.h"
|
||||
#include "config.h"
|
||||
#include "evutil.h"
|
||||
#include "./log.h"
|
||||
|
||||
struct evbuffer *
|
||||
evbuffer_new(void)
|
||||
@ -259,6 +260,9 @@ evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
|
||||
char *line;
|
||||
unsigned int i, n_to_copy, n_to_drain;
|
||||
|
||||
if (n_read_out)
|
||||
*n_read_out = 0;
|
||||
|
||||
/* depending on eol_style, set start_of_eol to the first character
|
||||
* in the newline, and end_of_eol to one after the last character. */
|
||||
switch (eol_style) {
|
||||
@ -317,8 +321,7 @@ evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
|
||||
n_to_drain = end_of_eol - data;
|
||||
|
||||
if ((line = malloc(n_to_copy+1)) == NULL) {
|
||||
fprintf(stderr, "%s: out of memory\n", __func__);
|
||||
evbuffer_drain(buffer, n_to_drain);
|
||||
event_warn("%s: out of memory\n", __func__);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user