P-p-H-d / mlib

Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).
BSD 2-Clause "Simplified" License
869 stars 76 forks source link

Add m_string_cat_vprintf #109

Closed kitterion closed 1 year ago

kitterion commented 1 year ago

It seems weird that there are both m_string_printf and m_string_vprintf but m_string_cat_printf doesn't have a vprintf variant, so here I add the missing function. I think because of this, flipperzero firmware (that uses m-string) has to allocate a new string in its string_cat_vprintf implementation instead of just delegating to an appropriate vprintf function, like it does in its string_vprintf here.

P-p-H-d commented 1 year ago

Hi,

Thank you for your contribution! I have reviewed the patch and I don't see anything wrong. Could you add some basic tests for this m_string_cat_printf function in test-mstring.c? Thanks.

kitterion commented 1 year ago

Sure, there are already some tests of string_cat_printf in there, would you like me to write some more?

P-p-H-d commented 1 year ago

Yes. Only a basic test of the function string_cat_vprintf is needed to ensure having a working user API. The coverage should already be ok since the coverage of string_cat_printf was ok (you can check coverage with "make coverage" which should give 100% for strings).

kitterion commented 1 year ago

I'm not exactly sure if this is what you meant, but I added some tests by essentially copying corresponding string_cat_printf tests. These are not new and unique, as I'm not sure that's required or even desired in this particular case.