Files
mop3/ce/context.c
kamkow1 c8fb575bdd
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 2m7s
Build documentation / build-and-deploy (push) Successful in 39s
Change formatting rules
2026-04-24 01:54:48 +02:00

32 lines
567 B
C

#include "context.h"
#include "strbuf.h"
#include <malloc.h>
#include <printf.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
void cprintf(struct context* context, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
char* buf = malloc(CPRINTF_BUF_MAX);
if (buf == NULL) {
va_end(args);
return;
}
memset(buf, 0, CPRINTF_BUF_MAX);
int len = vsnprintf(buf, CPRINTF_BUF_MAX, fmt, args);
va_end(args);
if (len > 0) {
for (int i = 0; i < len; i++)
strbuf_append(&context->strbuf, buf[i]);
}
free(buf);
}