diff --git a/docs/README.md b/docs/README.md index 935490ce..781aa861 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3192,12 +3192,18 @@ Return value: new `io` length Usage example: ```c -struct mg_iobuf io; -mg_iobuf_init(&io, 0); // Empty buffer -mg_iobuf_add(&io, 0, "hi", 2, 512); // io->len is 2, io->size is 512 +struct mg_iobuf io; // Declare buffer +mg_iobuf_init(&io, 0); // Initialise buffer to have 0 allocated bytes ``` -Function mg_iobuf_add() +Function mg_iobuf_init() + +```c +mg_iobuf_add(&io, 0, "hello", 5, 512); // Add "hello" at offset 0 +``` + +Function mg_iobuf_add() + ### mg\_iobuf\_del() diff --git a/docs/images/mg_commalist.svg b/docs/images/mg_commalist.svg new file mode 100644 index 00000000..3b2a50c1 --- /dev/null +++ b/docs/images/mg_commalist.svg @@ -0,0 +1,97 @@ + + + + + + + + + struct mg_str k,v,s = mg_str(”a=333, b=777”); + + + + + mg_commalist(&s, &k, &v); + + + + + mg_commalist(&s, &k, &v); + + + + + // 1st call + // 2nd call + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/mg_iobuf_add.png b/docs/images/mg_iobuf_add.png deleted file mode 100644 index d1fd940a..00000000 Binary files a/docs/images/mg_iobuf_add.png and /dev/null differ diff --git a/docs/images/mg_iobuf_add1.svg b/docs/images/mg_iobuf_add1.svg new file mode 100644 index 00000000..84ec4c5b --- /dev/null +++ b/docs/images/mg_iobuf_add1.svg @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + buf=NULL + + + non-allocated space + + + len=0 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + size=0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/images/mg_iobuf_add2.svg b/docs/images/mg_iobuf_add2.svg new file mode 100644 index 00000000..1179a4be --- /dev/null +++ b/docs/images/mg_iobuf_add2.svg @@ -0,0 +1,181 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + buf + + + + + + + + + + + len=5 + + + + + + + + + + + size=512 + + + + + + + + + + + + + + + + + + + + + + + + data + + + free space + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + non-allocated space + + + + + + + + + + + + + + + + + + + + + h + + + + + e + + + + + l + + + + + l + + + + + o + + + + +