mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-07 04:54:55 -04:00
6dd1600936
* Move qrand to libc64 * use an union to avoid type punning * __osMalloc * math64.c * fixed_point.h * sleep * aprintf.h * sprintf * malloc * use original names on aprintf.c and malloc.c * qrand cleanup pass * use original names of sleep.c * og names for sprintf * more cleanup * format * fixes * whoops * use ARRAY_COUNT again * comment * Use `fu` * forgot this one * review * fix * sneak a tiny cleanup
32 lines
597 B
C
32 lines
597 B
C
#include "libc64/sprintf.h"
|
|
|
|
#include "libc/string.h"
|
|
|
|
void* proutPrintf(void* dst, const char* fmt, size_t size) {
|
|
return (void*)((uintptr_t)memcpy(dst, fmt, size) + size);
|
|
}
|
|
|
|
int vsprintf(char* dst, const char* fmt, va_list args) {
|
|
int ans = _Printf(proutPrintf, dst, fmt, args);
|
|
|
|
if (ans > -1) {
|
|
dst[ans] = 0;
|
|
}
|
|
return ans;
|
|
}
|
|
|
|
int sprintf(char* dst, const char* fmt, ...) {
|
|
int ans;
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
|
|
ans = _Printf(&proutPrintf, dst, fmt, args);
|
|
if (ans > -1) {
|
|
dst[ans] = 0;
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
return ans;
|
|
}
|