[systemd-devel] [PATCH 1/2] Use heap allocation for stdout journald buffer
Zbigniew Jędrzejewski-Szmek
zbyszek at in.waw.pl
Tue Dec 10 04:18:48 PST 2013
On Sun, Dec 08, 2013 at 11:32:33AM -0600, Dan McGee wrote:
>
> - l = read(s->fd, s->buffer+s->length, sizeof(s->buffer)-1-s->length);
> + l = read(s->fd, s->buffer+s->length, s->size-1-s->length);
Please add some spaces here around + and - operators.
> if (l < 0) {
>
> if (errno == EAGAIN)
> @@ -339,6 +341,7 @@ void stdout_stream_free(StdoutStream *s) {
> freecon(s->security_context);
> #endif
>
> + free(s->buffer);
> free(s->identifier);
> free(s);
> }
> @@ -371,6 +374,13 @@ int stdout_stream_new(Server *s) {
> close_nointr_nofail(fd);
> return log_oom();
> }
> + stream->buffer = malloc0(LINE_MAX);
> + if (!stream->buffer) {
> + free(stream);
> + close_nointr_nofail(fd);
> + return log_oom();
> + }
> + stream->size = LINE_MAX;
Just call stdout_stream_free instead.
Zbyszek
More information about the systemd-devel
mailing list