From 66d4e9300bd8b4be4f1d759146a92df7fd3230a1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 14 Apr 2018 13:59:33 +0200 Subject: Logging: replace 'fwrite' w/ 'write' We're already buffing output, so use write directly. --- intern/clog/clog.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/intern/clog/clog.c b/intern/clog/clog.c index dfbd34d341a..b26105be351 100644 --- a/intern/clog/clog.c +++ b/intern/clog/clog.c @@ -68,7 +68,8 @@ typedef struct CLogContext { bool use_basename; /** Borrowed, not owned. */ - FILE *output; + int output; + FILE *output_file; /** For new types. */ struct { @@ -400,13 +401,12 @@ void CLG_log_str( clg_str_append(&cstr, "\n"); /* could be optional */ - fwrite(cstr.data, cstr.len, 1, lg->ctx->output); - fflush(lg->ctx->output); + write(lg->ctx->output, cstr.data, cstr.len); clg_str_free(&cstr); if (severity == CLG_SEVERITY_FATAL) { - clg_ctx_fatal_action(lg->ctx, lg->ctx->output); + clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file); } } @@ -432,13 +432,12 @@ void CLG_logf( clg_str_append(&cstr, "\n"); /* could be optional */ - fwrite(cstr.data, cstr.len, 1, lg->ctx->output); - fflush(lg->ctx->output); + write(lg->ctx->output, cstr.data, cstr.len); clg_str_free(&cstr); if (severity == CLG_SEVERITY_FATAL) { - clg_ctx_fatal_action(lg->ctx, lg->ctx->output); + clg_ctx_fatal_action(lg->ctx, lg->ctx->output_file); } } @@ -450,9 +449,10 @@ void CLG_logf( static void CLG_ctx_output_set(CLogContext *ctx, void *file_handle) { - ctx->output = file_handle; + ctx->output_file = file_handle; + ctx->output = fileno(file_handle); #if defined(__unix__) - ctx->use_color = isatty(fileno(file_handle)); + ctx->use_color = isatty(ctx->output); #endif } -- cgit v1.2.3