mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 10:29:45 +01: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:
parent
eb9d3582d8
commit
5133d58777
2 changed files with 15 additions and 0 deletions
|
@ -335,3 +335,12 @@ bool endsWith(const char* str, const char* suffix)
|
||||||
|
|
||||||
return SDL_strcmp(&str[str_size - suffix_size], suffix) == 0;
|
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';
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,12 @@ bool is_positive_num(const char* str, const bool hex);
|
||||||
|
|
||||||
bool endsWith(const char* str, const char* suffix);
|
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_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))
|
#define INBOUNDS_ARR(index, array) ((int) index >= 0 && (int) index < (int) SDL_arraysize(array))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue