Skip to content

Commit

Permalink
[Android] Fix double use of va_list argument in kinc_log_args [fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanva committed Apr 11, 2024
1 parent 2c79b4d commit 45aefc2
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions Sources/kinc/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ void kinc_log(kinc_log_level_t level, const char *format, ...) {
#define UTF8

void kinc_log_args(kinc_log_level_t level, const char *format, va_list args) {
#ifdef KINC_ANDROID
va_list args_android_copy;
va_copy(args_android_copy, args);
switch (level) {
case KINC_LOG_LEVEL_INFO:
__android_log_vprint(ANDROID_LOG_INFO, "Kinc", format, args_android_copy);
break;
case KINC_LOG_LEVEL_WARNING:
__android_log_vprint(ANDROID_LOG_WARN, "Kinc", format, args_android_copy);
break;
case KINC_LOG_LEVEL_ERROR:
__android_log_vprint(ANDROID_LOG_ERROR, "Kinc", format, args_android_copy);
break;
}
va_end(args_android_copy);
#endif
#ifdef KINC_MICROSOFT
#ifdef UTF8
wchar_t buffer[4096];
Expand All @@ -112,20 +128,6 @@ void kinc_log_args(kinc_log_level_t level, const char *format, va_list args) {
strcat(buffer, "\n");
fprintf(level == KINC_LOG_LEVEL_INFO ? stdout : stderr, "%s", buffer);
#endif

#ifdef KINC_ANDROID
switch (level) {
case KINC_LOG_LEVEL_INFO:
__android_log_vprint(ANDROID_LOG_INFO, "Kinc", format, args);
break;
case KINC_LOG_LEVEL_WARNING:
__android_log_vprint(ANDROID_LOG_WARN, "Kinc", format, args);
break;
case KINC_LOG_LEVEL_ERROR:
__android_log_vprint(ANDROID_LOG_ERROR, "Kinc", format, args);
break;
}
#endif
}

#endif
Expand Down

0 comments on commit 45aefc2

Please sign in to comment.