gbasys
changeset 11:2b31bd7e96b4
added panicf
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 01 Feb 2016 02:36:25 +0200 |
parents | 9d05431f4a16 |
children | a6ddf338a111 |
files | src/error.c src/error.h |
diffstat | 2 files changed, 17 insertions(+), 2 deletions(-) [+] |
line diff
1.1 --- a/src/error.c Sat Jan 30 05:23:48 2016 +0200 1.2 +++ b/src/error.c Mon Feb 01 02:36:25 2016 +0200 1.3 @@ -1,6 +1,6 @@ 1.4 /* 1.5 gbasys - a gameboy advance hardware abstraction library 1.6 -Copyright (C) 2004-2014 John Tsiombikas <nuclear@member.fsf.org> 1.7 +Copyright (C) 2004-2016 John Tsiombikas <nuclear@member.fsf.org> 1.8 1.9 This program is free software: you can redistribute it and/or modify 1.10 it under the terms of the GNU General Public License as published by 1.11 @@ -15,6 +15,8 @@ 1.12 You should have received a copy of the GNU General Public License 1.13 along with this program. If not, see <http://www.gnu.org/licenses/>. 1.14 */ 1.15 +#include <stdio.h> 1.16 +#include <stdarg.h> 1.17 #include "gfx.h" 1.18 1.19 void panic(const char *str) { 1.20 @@ -28,3 +30,15 @@ 1.21 1.22 for(;;); 1.23 } 1.24 + 1.25 +void panicf(const char *fmt, ...) 1.26 +{ 1.27 + static char buf[64]; 1.28 + va_list ap; 1.29 + 1.30 + va_start(ap, fmt); 1.31 + vsnprintf(buf, sizeof buf - 1, fmt, ap); 1.32 + va_end(ap); 1.33 + 1.34 + panic(buf); 1.35 +}
2.1 --- a/src/error.h Sat Jan 30 05:23:48 2016 +0200 2.2 +++ b/src/error.h Mon Feb 01 02:36:25 2016 +0200 2.3 @@ -1,6 +1,6 @@ 2.4 /* 2.5 gbasys - a gameboy advance hardware abstraction library 2.6 -Copyright (C) 2004-2014 John Tsiombikas <nuclear@member.fsf.org> 2.7 +Copyright (C) 2004-2016 John Tsiombikas <nuclear@member.fsf.org> 2.8 2.9 This program is free software: you can redistribute it and/or modify 2.10 it under the terms of the GNU General Public License as published by 2.11 @@ -19,5 +19,6 @@ 2.12 #define _ERROR_H_ 2.13 2.14 void panic(const char *str); 2.15 +void panicf(const char *fmt, ...); 2.16 2.17 #endif /* _ERROR_H_ */