From d1b4cfde55d1ba163047cb49b1305452be6f66fc Mon Sep 17 00:00:00 2001 From: rsc Date: Wed, 9 Jun 2004 14:12:04 +0000 Subject: [PATCH] use plan9 malloc --- src/lib9/fmt/fmtdef.h | 3 +++ src/lib9/fmt/fmtstr.c | 7 ++----- src/lib9/fmt/runefmtstr.c | 7 ++----- src/lib9/fmt/vsmprint.c | 3 +-- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h index ca2010ab..89468767 100644 --- a/src/lib9/fmt/fmtdef.h +++ b/src/lib9/fmt/fmtdef.h @@ -25,7 +25,9 @@ #define vlong _fmtvlong #define uvlong _fmtuvlong +#ifndef USED #define USED(x) if(x);else +#endif typedef unsigned char uchar; typedef unsigned short ushort; @@ -37,6 +39,7 @@ typedef unsigned long long uvlong; typedef long long vlong; #endif +#undef nil #define nil 0 /* cannot be ((void*)0) because used for function pointers */ typedef int (*Fmts)(Fmt*); diff --git a/src/lib9/fmt/fmtstr.c b/src/lib9/fmt/fmtstr.c index 7af1fa24..0b227166 100644 --- a/src/lib9/fmt/fmtstr.c +++ b/src/lib9/fmt/fmtstr.c @@ -11,11 +11,8 @@ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -#include -#include -#include -#include "utf.h" -#include "fmt.h" +#include +#include #include "fmtdef.h" static int diff --git a/src/lib9/fmt/runefmtstr.c b/src/lib9/fmt/runefmtstr.c index a2ec6cb4..9ec84cd0 100644 --- a/src/lib9/fmt/runefmtstr.c +++ b/src/lib9/fmt/runefmtstr.c @@ -11,11 +11,8 @@ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -#include -#include -#include -#include "utf.h" -#include "fmt.h" +#include +#include #include "fmtdef.h" static int diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c index 38ace62d..34a1b36f 100644 --- a/src/lib9/fmt/vsmprint.c +++ b/src/lib9/fmt/vsmprint.c @@ -31,6 +31,5 @@ vsmprint(char *fmt, va_list args) n = dofmt(&f, fmt); if(n < 0) return nil; - *(char*)f.to = '\0'; - return (char*)f.start; + return fmtstrflush(&f); }