1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-25 05:58:30 +02:00

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';
}

View File

@ -28,6 +28,12 @@ bool is_positive_num(const char* str, const bool hex);
bool endsWith(const char* str, const char* suffix);
void VVV_fillstring(
char* buffer,
const size_t buffer_size,
const char fillchar
);
#define INBOUNDS_VEC(index, vector) ((int) index >= 0 && (int) index < (int) vector.size())
#define INBOUNDS_ARR(index, array) ((int) index >= 0 && (int) index < (int) SDL_arraysize(array))