This function accepts an WCHAR input and checks its length. If too long, only N characters are copied to the local string. Here is that code.
There is preceding code puts the current time into the beginning of build_string. Variable count_of_time_characters is that count. Constant MAX_LOG_STRING_LENGTH is the length of build_string.
if( (count_from_caller + count_of_time_characters) < MAX_LOG_STRING_LENGTH ) { wcscat_s( build_string, MAX_LOG_STRING_LENGTH, caller_text_to_log ); } else // it does not fit { // Copy what will fit into the write string size_t copy_count = MAX_LOG_STRING_LENGTH - ( count_of_time_characters + 1 ); errno_t copy_status = wcsncpy_s( &build_string[ count_of_time_characters ], copy_count, caller_text_to_log, _TRUNCATE ); ... }
The code behaves as expected but the return value of 0x050 or 80 decimal is unexpected. The MSDN/Help page says it should return zero on success, EINVAL (22 decimal), or ERANGE (34 decimal). The actual character count is 384 decimal. GetLastError() returns zero, but the help page does not mention GetLastError().
Where can I determine the meaning of this value of 80? The final string looks correct, but I am hesitant to just ignore the non-zero return value.
~jag77 We need to know what a dragon is before we study its anatomy. (Bryan Kelly, 2010)