Fix stagetext_add_numeric
Pass correct buffer size, get rid of NUM_PLACEHOLDER nonsense. Also update format_huge_num signature to identify buf as char[bufsize]
This commit is contained in:
parent
adeca742ec
commit
76a60d92a9
3 changed files with 4 additions and 7 deletions
|
@ -14,8 +14,6 @@
|
|||
|
||||
static StageText *textlist = NULL;
|
||||
|
||||
#define NUM_PLACEHOLDER "........................"
|
||||
|
||||
StageText* stagetext_add(const char *text, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
|
||||
StageText *t = (StageText*)objpool_acquire(stage_object_pools.stagetext);
|
||||
list_append(&textlist, t);
|
||||
|
@ -39,12 +37,11 @@ StageText* stagetext_add(const char *text, cmplx pos, Alignment align, Font *fon
|
|||
}
|
||||
|
||||
static void stagetext_numeric_update(StageText *txt, int t, float a) {
|
||||
// snprintf(txt->text, sizeof(NUM_PLACEHOLDER), "%i", (int)((intptr_t)txt->custom.data1 * pow(a, 5)));
|
||||
format_huge_num(0, (uintptr_t)txt->custom.data1 * pow(a, 5), sizeof(NUM_PLACEHOLDER), txt->text);
|
||||
format_huge_num(0, (uintptr_t)txt->custom.data1 * pow(a, 5), sizeof(txt->text), txt->text);
|
||||
}
|
||||
|
||||
StageText* stagetext_add_numeric(int n, cmplx pos, Alignment align, Font *font, const Color *clr, int delay, int lifetime, int fadeintime, int fadeouttime) {
|
||||
StageText *t = stagetext_add(NUM_PLACEHOLDER, pos, align, font, clr, delay, lifetime, fadeintime, fadeouttime);
|
||||
StageText *t = stagetext_add(NULL, pos, align, font, clr, delay, lifetime, fadeintime, fadeouttime);
|
||||
t->custom.data1 = (void*)(intptr_t)n;
|
||||
t->custom.update = stagetext_numeric_update;
|
||||
return t;
|
||||
|
|
|
@ -409,7 +409,7 @@ uint32_t utf8_getch(const char **src) {
|
|||
return ch;
|
||||
}
|
||||
|
||||
void format_huge_num(uint digits, uint64_t num, size_t bufsize, char *buf) {
|
||||
void format_huge_num(uint digits, uint64_t num, size_t bufsize, char buf[bufsize]) {
|
||||
if(digits == 0) {
|
||||
digits = digitcnt(num);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ uint32_t utf8_getch(const char **src) attr_nonnull(1);
|
|||
|
||||
uint32_t crc32str(uint32_t crc, const char *str);
|
||||
|
||||
void format_huge_num(uint digits, uint64_t num, size_t bufsize, char *buf);
|
||||
void format_huge_num(uint digits, uint64_t num, size_t bufsize, char buf[bufsize]);
|
||||
void hexdigest(uint8_t *input, size_t input_size, char *output, size_t output_size);
|
||||
|
||||
#define FILENAME_TIMESTAMP_MIN_BUF_SIZE 23
|
||||
|
|
Loading…
Reference in a new issue