aboutsummaryrefslogtreecommitdiff
path: root/screenbuffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'screenbuffer.cpp')
-rw-r--r--screenbuffer.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/screenbuffer.cpp b/screenbuffer.cpp
index a382e82..d224181 100644
--- a/screenbuffer.cpp
+++ b/screenbuffer.cpp
@@ -74,35 +74,32 @@ void ScreenBuffer::printstr(const char *buf){
}
}
-__attribute__((format (printf, 2, 3)))
-int ScreenBuffer::printf(const char *format,...){
- va_list ap;
- va_start(ap,format);
+int ScreenBuffer::printf_varargs(const char *format,va_list ap){
char *buf;
int ret=vasprintf(&buf,format,ap);
- va_end(ap);
assert(buf);
-
printstr(buf);
-
free(buf);
return ret;
}
+__attribute__((format (printf, 2, 3)))
+int ScreenBuffer::printf(const char *format,...){
+ va_list ap;
+ va_start(ap,format);
+ int ret=printf_varargs(format,ap);
+ va_end(ap);
+ return ret;
+}
+
__attribute__((format (printf, 4, 5)))
int ScreenBuffer::mvprintf(int x,int y,const char *format,...){
moveto(x,y);
va_list ap;
va_start(ap,format);
- char *buf;
- int ret=vasprintf(&buf,format,ap);
+ int ret=printf_varargs(format,ap);
va_end(ap);
- assert(buf);
-
- printstr(buf);
-
- free(buf);
return ret;
}