fix: replace unsafe fixed-size buffers with dynamic formatting helpers; add util format helpers; centralize log_on_line cleanup
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#ifndef UTIL_H
|
||||
#define UTIL_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Formats a string using printf-style formatting and returns a newly allocated string.
|
||||
* The caller is responsible for freeing the returned string.
|
||||
*
|
||||
* @param fmt The format string.
|
||||
* @param ... The values to format.
|
||||
* @return A newly allocated string containing the formatted output.
|
||||
*/
|
||||
char* format_string(const char* fmt, ...);
|
||||
|
||||
/**
|
||||
* Formats a string using printf-style formatting with a va_list and returns a newly allocated string.
|
||||
* The caller is responsible for freeing the returned string.
|
||||
*
|
||||
* @param fmt The format string.
|
||||
* @param args The va_list of values to format.
|
||||
* @return A newly allocated string containing the formatted output.
|
||||
*/
|
||||
char* format_string_va(const char* fmt, va_list args);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user