Add VVV_fillstring()

This function is simple - it takes a given buffer and its size, fills it
with a certain character, and null-terminates it. It's meant to be used
with freshly-created buffers, so we don't copy-paste code.
This commit is contained in:
Misa
2021-04-11 17:19:53 -07:00
committed by Ethan Lee
parent eb9d3582d8
commit 5133d58777
2 changed files with 15 additions and 0 deletions

View File

@@ -335,3 +335,12 @@ bool endsWith(const char* str, const char* suffix)
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
}
void VVV_fillstring(
char* buffer,
const size_t buffer_size,
const char fillchar
) {
SDL_memset(buffer, fillchar, buffer_size - 1);
buffer[buffer_size - 1] = '\0';
}