mirror of https://github.com/zeldaret/mm.git
printutils OK, add `va_end` to variadic functions (#294)
* printutils OK * Add va_end to every variadic function
This commit is contained in:
parent
2ff7320409
commit
9e4d51fb9f
|
@ -236,8 +236,8 @@ u32 __osCheckArena(Arena* heap);
|
||||||
void* proutSprintf(void* s, const char* buf, size_t n);
|
void* proutSprintf(void* s, const char* buf, size_t n);
|
||||||
s32 vsprintf(char* dst, char* fmt, va_list args);
|
s32 vsprintf(char* dst, char* fmt, va_list args);
|
||||||
s32 sprintf(char* s, char* fmt, ...);
|
s32 sprintf(char* s, char* fmt, ...);
|
||||||
void PrintUtils_VPrintf(void* callback, const char* fmt, va_list args);
|
void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);
|
||||||
// void PrintUtils_Printf(void);
|
void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...);
|
||||||
void Sleep_Cycles(OSTime time);
|
void Sleep_Cycles(OSTime time);
|
||||||
// void Sleep_Nsec(void);
|
// void Sleep_Nsec(void);
|
||||||
void Sleep_Usec(s32);
|
void Sleep_Usec(s32);
|
||||||
|
|
|
@ -172,7 +172,7 @@ Gfx* GfxPrint_Close(GfxPrint* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) {
|
void GfxPrint_VPrintf(GfxPrint* this, const char* fmt, va_list args) {
|
||||||
PrintUtils_VPrintf(&this->callback, fmt, args);
|
PrintUtils_VPrintf((PrintCallback*)&this->callback, fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) {
|
void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) {
|
||||||
|
@ -180,4 +180,6 @@ void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...) {
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
GfxPrint_VPrintf(this, fmt, args);
|
GfxPrint_VPrintf(this, fmt, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,14 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/non_matchings/boot/printutils/PrintUtils_VPrintf.s")
|
void PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args) {
|
||||||
|
_Printf(*pfn, pfn, fmt, args);
|
||||||
|
}
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/non_matchings/boot/printutils/PrintUtils_Printf.s")
|
void PrintUtils_Printf(PrintCallback* pfn, const char* fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
PrintUtils_VPrintf(pfn, fmt, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
|
@ -153,6 +153,8 @@ void FaultDrawer_Printf(const char* fmt, ...) {
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
FaultDrawer_VPrintf(fmt, args);
|
FaultDrawer_VPrintf(fmt, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) {
|
void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) {
|
||||||
|
@ -161,6 +163,8 @@ void FaultDrawer_DrawText(s32 x, s32 y, const char* fmt, ...) {
|
||||||
|
|
||||||
FaultDrawer_SetCursor(x, y);
|
FaultDrawer_SetCursor(x, y);
|
||||||
FaultDrawer_VPrintf(fmt, args);
|
FaultDrawer_VPrintf(fmt, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h) {
|
void FaultDrawer_SetDrawerFB(void* fb, u16 w, u16 h) {
|
||||||
|
|
|
@ -14,12 +14,15 @@ int vsprintf(char* dst, char* fmt, va_list args) {
|
||||||
|
|
||||||
int sprintf(char* dst, char* fmt, ...) {
|
int sprintf(char* dst, char* fmt, ...) {
|
||||||
int ans;
|
int ans;
|
||||||
va_list ap;
|
va_list args;
|
||||||
va_start(ap, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
ans = _Printf(&proutSprintf, dst, fmt, ap);
|
ans = _Printf(&proutSprintf, dst, fmt, args);
|
||||||
if (ans > -1) {
|
if (ans > -1) {
|
||||||
dst[ans] = 0;
|
dst[ans] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue