Split CE code into multiple files
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m38s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m38s
This commit is contained in:
29
ce/context.c
Normal file
29
ce/context.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "context.h"
|
||||
#include "strbuf.h"
|
||||
#include <liballoc.h>
|
||||
#include <printf.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user