ソースを参照

libdpkg: Switch log from a pointer to struct varbuf to just struct varbuf

Guillem Jover 18 年 前
コミット
5a1ee0e65b
共有2 個のファイルを変更した10 個の追加10 個の削除を含む
  1. 5 0
      ChangeLog
  2. 5 10
      lib/log.c

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+2008-06-04  Guillem Jover  <guillem@debian.org>
+
+	* lib/log.c (log_message): Switch log from a pointer to struct varbuf
+	to just struct varbuf.
+
 2008-06-04  Guillem Jover  <guillem@debian.org>
 
 	* src/main.c (setpipe): Fix the setting of more than one pipef.

+ 5 - 10
lib/log.c

@@ -36,7 +36,7 @@ const char *log_file = NULL;
 void
 log_message(const char *fmt, ...)
 {
-	static struct varbuf *log = NULL;
+	static struct varbuf log;
 	static FILE *logfd = NULL;
 	char time_str[20];
 	time_t now;
@@ -57,21 +57,16 @@ log_message(const char *fmt, ...)
 		setcloexec(fileno(logfd), log_file);
 	}
 
-	if (!log) {
-		log = nfmalloc(sizeof(struct varbuf));
-		varbufinit(log);
-	} else
-		varbufreset(log);
-
 	va_start(al, fmt);
-	varbufvprintf(log, fmt, al);
-	varbufaddc(log, 0);
+	varbufreset(&log);
+	varbufvprintf(&log, fmt, al);
+	varbufaddc(&log, 0);
 	va_end(al);
 
 	time(&now);
 	strftime(time_str, sizeof(time_str), "%Y-%m-%d %H:%M:%S",
 	         localtime(&now));
-	fprintf(logfd, "%s %s\n", time_str, log->buf);
+	fprintf(logfd, "%s %s\n", time_str, log.buf);
 }
 
 struct pipef *status_pipes = NULL;