Move mg_a*printf to common

PUBLISHED_FROM=cccd28ef43ec4e08fa52340ce78bda10db5ac27a
This commit is contained in:
Marko Mikulicic authored and Cesanta Bot committed 2016-11-18 15:36:00 +00:00
1 parent 9dba6c806b
commit a23daa1547
5 files changed
+73 -99

No files matched your search

-2
View File
@@ -3,8 +3,6 @@ title: "Utility API"
symbol_kind: "intro"
decl_name: "util.h"
items:
- { name: mg_asprintf.md }
- { name: mg_avprintf.md }
- { name: mg_base64_decode.md }
- { name: mg_base64_encode.md }
- { name: mg_basic_auth_header.md }
-22
View File
@@ -1,22 +0,0 @@
---
title: "mg_asprintf()"
decl_name: "mg_asprintf"
symbol_kind: "func"
signature: |
int mg_asprintf(char **buf, size_t size, const char *fmt, ...);
---
Prints message to the buffer. If the buffer is large enough to hold the
message, it returns buffer. If buffer is to small, it allocates a large
enough buffer on heap and returns allocated buffer.
This is a supposed use case:
char buf[5], *p = buf;
mg_avprintf(&p, sizeof(buf), "%s", "hi there");
use_p_somehow(p);
if (p != buf) {
free(p);
}
The purpose of this is to avoid malloc-ing if generated strings are small.
-10
View File
@@ -1,10 +0,0 @@
---
title: "mg_avprintf()"
decl_name: "mg_avprintf"
symbol_kind: "func"
signature: |
int mg_avprintf(char **buf, size_t size, const char *fmt, va_list ap);
---
Same as mg_asprintf, but takes varargs list.