benilla-re systems structs docs

__snprintf

function · crt · primitive

Address
0x740107 · 81 bytes, up to 0x740157
Signature
int __cdecl (char *buffer, size_t count, const char *format, ...)
Meaning
Formats into count bytes through __output, with a NUL only when room is left; -1 when the text is longer
Confidence
verified, proof one
Name from
the community database (idb)
Finding
crt/printf#the-string-front-ends
Test
crt::crt_snprintf_vsprintf_difftest

Finding: The string front ends in crt: formatted output

sprintf and _vsprintf give __output the count 0x7fffffff; _snprintf and _vsnprintf give it the caller's count, as a signed int. One more decrement of the count then decides the end: at zero or above, a NUL at the cursor; below zero, nothing. So a text shorter than the count ends in a NUL and returns its length; a text of exactly the count has no NUL and returns the count; a longer one stops at the count with no NUL and returns -1. A count of 0 or from 0x80000001 up leaves no room: nothing is written, and the return is -1, or 0 for an empty text. 0x80000000 wraps to 0x7fffffff on its first decrement and has no bound.

The derivation is in the doc.

Callers 2

Callees 2

Calls and jumps by a bare address, from tables/calls.tsv.