[Bf-blender-cvs] [66d4e9300bd] master: Logging: replace 'fwrite' w/ 'write'

Campbell Barton noreply at git.blender.org
Sat Apr 14 14:01:58 CEST 2018


Commit: 66d4e9300bd8b4be4f1d759146a92df7fd3230a1
Author: Campbell Barton
Date:   Sat Apr 14 13:59:33 2018 +0200
Branches: master
https://developer.blender.org/rB66d4e9300bd8b4be4f1d759146a92df7fd3230a1

Logging: replace 'fwrite' w/ 'write'

We're already buffing output, so use write directly.

===================================================================

M	intern/clog/clog.c

===================================================================

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
 }



More information about the Bf-blender-cvs mailing list