Skip to content

Commit dbe9749

Browse files
committed
Add sprintf to minimal-printf implementation
1 parent 2d3c402 commit dbe9749

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

TESTS/mbed_platform/minimal-printf/compliance/mbed_printf.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ int mbed_snprintf(char *buffer, size_t length, const char *format, ...)
3939
return result;
4040
}
4141

42+
int mbed_sprintf(char *buffer, const char *format, ...)
43+
{
44+
va_list arguments;
45+
va_start(arguments, format);
46+
int result = mbed_minimal_formatted_string(buffer, LONG_MAX, format, arguments, NULL);
47+
va_end(arguments);
48+
49+
return result;
50+
}
51+
4252
int mbed_vprintf(const char *format, va_list arguments)
4353
{
4454
return mbed_minimal_formatted_string(NULL, LONG_MAX, format, arguments, stdout);

TESTS/mbed_platform/minimal-printf/compliance/mbed_printf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ int mbed_printf(const char *format, ...);
3838
*/
3939
int mbed_snprintf(char *buffer, size_t length, const char *format, ...);
4040

41+
/**
42+
* Minimal snprintf
43+
*
44+
* Prints directly to buffer without using malloc.
45+
*/
46+
int mbed_sprintf(char *buffer, const char *format, ...);
47+
4148
/**
4249
* Minimal printf
4350
*

0 commit comments

Comments
 (0)