Skip to content

Commit

Permalink
Allow formatted strings with S2D_Error
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktm committed Sep 19, 2018
1 parent 33cacc5 commit 7632eb6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/simple2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void S2D_Log(int type, const char *msg, ...);
/*
* Logs Simple 2D errors to the console, with caller and message body
*/
void S2D_Error(const char *caller, const char *msg);
void S2D_Error(const char *caller, const char *msg, ...);

/*
* Enable/disable logging of diagnostics
Expand Down
10 changes: 8 additions & 2 deletions src/simple2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ void S2D_Log(int type, const char *msg, ...) {
/*
* Logs Simple 2D errors to the console, with caller and message body
*/
void S2D_Error(const char *caller, const char *msg) {
S2D_Log(S2D_ERROR, "(%s) %s", caller, msg);
void S2D_Error(const char *caller, const char *msg, ...) {
va_list args;
va_start(args, msg);
char *fmsg;
vasprintf(&fmsg, msg, args);
S2D_Log(S2D_ERROR, "(%s) %s", caller, fmsg);
free(fmsg);
va_end(args);
}


Expand Down

0 comments on commit 7632eb6

Please sign in to comment.