Skip to content

Commit

Permalink
internal_vprintf was wrong
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemoralis committed Feb 21, 2025
1 parent 745cdd8 commit a4a8bf7
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions src/core/libraries/libc_internal/libc_internal_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,35 +152,9 @@ s32 PS4_SYSV_ABI internal_vfwscanf_s() {
return ORBIS_OK;
}

s32 PS4_SYSV_ABI internal_vprintf(const char* format, va_list args) {
// Copy the va_list because vsnprintf consumes it
va_list args_copy;
va_copy(args_copy, args);

// Calculate the required buffer size
int size = std::vsnprintf(nullptr, 0, format, args_copy);
va_end(args_copy);

if (size < 0) {
// Handle vsnprintf error
LOG_ERROR(Lib_LibcInternal, "vsnprintf failed to calculate size");
return size;
}

// Create a string with the required size
std::string buffer(size, '\0');

// Format the string into the buffer
int result =
std::vsnprintf(buffer.data(), buffer.size() + 1, format, args); // +1 for null terminator
if (result >= 0) {
// Log the formatted result
LOG_INFO(Lib_LibcInternal, "{}", buffer);
} else {
LOG_ERROR(Lib_LibcInternal, "vsnprintf failed during formatting");
}

return result;
s32 PS4_SYSV_ABI internal_vprintf() {
LOG_ERROR(Lib_LibcInternal, "(STUBBED) called");
return ORBIS_OK;
}

s32 PS4_SYSV_ABI internal_vprintf_s() {
Expand Down

0 comments on commit a4a8bf7

Please # to comment.