Mercurial
view third_party/wrk/src/aprintf.c @ 262:0f45474c1b1a
Add cyberpunk JRPG blog browser
Show the latest posts in the JRPG preview and render the full blog archive and sanitized post details in the Inspect modal.
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <mrjunejune@users.noreply.github.com> |
|---|---|
| date | Thu, 06 Aug 2026 04:08:45 -0700 |
| parents | 94705b5986b3 |
| children |
line wrap: on
line source
// Copyright (C) 2012 - Will Glozer. All rights reserved. #include <stdarg.h> #include <stdlib.h> #include <stdio.h> #include <string.h> char *aprintf(char **s, const char *fmt, ...) { char *c = NULL; int n, len; va_list ap; va_start(ap, fmt); n = vsnprintf(NULL, 0, fmt, ap) + 1; va_end(ap); len = *s ? strlen(*s) : 0; if ((*s = realloc(*s, (len + n) * sizeof(char)))) { c = *s + len; va_start(ap, fmt); vsnprintf(c, n, fmt, ap); va_end(ap); } return c; }