MCPcopy Create free account
hub / github.com/FastLED/FastLED / snprintf

Function snprintf

src/fl/stl/stdio.h:666–694  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664/// @endcode
665template<typename... Args>
666int snprintf(char* buffer, fl::size size, const char* format, const Args&... args) FL_NOEXCEPT {
667 // Handle null buffer or zero size
668 if (!buffer || size == 0) {
669 return 0;
670 }
671
672 // Format to internal string stream
673 sstream stream;
674 printf_detail::format_impl(stream, format, args...);
675 fl::string result = stream.str();
676
677 // Get the formatted string length
678 fl::size formatted_len = result.size();
679
680 // Copy to buffer, ensuring null termination
681 fl::size copy_len = (formatted_len < size - 1) ? formatted_len : size - 1;
682
683 // Copy characters
684 for (fl::size i = 0; i < copy_len; ++i) {
685 buffer[i] = result[i];
686 }
687
688 // Null terminate
689 buffer[copy_len] = '\0';
690
691 // Return the number of characters actually written (excluding null terminator)
692 // This respects the buffer size limit instead of returning the full formatted length
693 return static_cast<int>(copy_len);
694}
695
696/// @brief Sprintf-like formatting function that writes to a buffer
697/// @param buffer Output buffer to write formatted string to

Callers 15

getKeyNameMethod · 0.85
sendHttpRequestHeaderMethod · 0.85
chunkOverheadMethod · 0.85
writeChunkMethod · 0.85
idToStringMethod · 0.85
sprintfFunction · 0.85
handle_esp_requestMethod · 0.85
connectMethod · 0.85
printfMethod · 0.85
generateNonceMethod · 0.85
verifyAuthMethod · 0.85
handleFirmwareUploadMethod · 0.85

Calls 3

format_implFunction · 0.70
strMethod · 0.45
sizeMethod · 0.45

Tested by 1

getPortFunction · 0.68