s n p r i n t f Provide a single place to deal with vsnprintf and error detection.
| 346 | // *************** |
| 347 | // Provide a single place to deal with vsnprintf and error detection. |
| 348 | int snprintf(char* buffer, size_t count, const char* format...) |
| 349 | { |
| 350 | va_list args; |
| 351 | va_start(args, format); |
| 352 | const int rc = VSNPRINTF(buffer, count, format, args); |
| 353 | buffer[count - 1] = 0; |
| 354 | va_end(args); |
| 355 | #if defined(DEV_BUILD) && !defined(HAVE_VSNPRINTF) |
| 356 | // We don't have the safe functions, then check if we overflowed the buffer. |
| 357 | // I would prefer to make this functionality available in prod build, too. |
| 358 | // If the docs are right, the null terminator is not counted => rc < count. |
| 359 | #if defined(fb_assert_continue) |
| 360 | fb_assert_continue(rc >= 0 && rc < count); |
| 361 | #else |
| 362 | fb_assert(rc >= 0 && rc < count); |
| 363 | #endif |
| 364 | #endif |
| 365 | return rc; |
| 366 | } |
| 367 | |
| 368 | // ******************* |
| 369 | // c l e a n u p _ p a s s w d |
no outgoing calls
no test coverage detected