Refactor queue

This commit is contained in:
cpq committed 2023-02-15 18:53:44 +00:00
1 parent 8aa26fb2cd
commit 515e438d4f
17 files changed
+279 -247

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
size_t mg_queue_vprintf(struct mg_queue *q, const char *fmt, va_list *ap) {
size_t len = mg_snprintf(NULL, 0, fmt, ap);
char *buf;
if (mg_queue_space(q, &buf) < len + 1) {
if (len == 0 || mg_queue_book(q, &buf, len + 1) < len + 1) {
len = 0; // Nah. Not enough space
} else {
len = mg_vsnprintf((char *)buf, len + 1, fmt, ap);