summaryrefslogtreecommitdiff
path: root/docs/reference/src/api/msg/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/reference/src/api/msg/index.md')
-rw-r--r--docs/reference/src/api/msg/index.md25
1 files changed, 13 insertions, 12 deletions
diff --git a/docs/reference/src/api/msg/index.md b/docs/reference/src/api/msg/index.md
index 1a7bdabf..54d8d9b8 100644
--- a/docs/reference/src/api/msg/index.md
+++ b/docs/reference/src/api/msg/index.md
@@ -48,25 +48,26 @@ that would affect the binary representation of the `nng_msg` itself.
### Example 1: Preparing a message for use
```c
-#include <nng/nng.h>
-nng_msg *m;
-if (nng_msg_alloc(&m, strlen("content") + 1) != 0) {
- // handle error
-}
-strcpy(nng_msg_body(m), "content");
+ #include <nng/nng.h>
+
+ nng_msg *m;
+ if (nng_msg_alloc(&m, strlen("content") + 1) != 0) {
+ // handle error
+ }
+ strcpy(nng_msg_body(m), "content");
```
### Example 2: Preallocating message content
```c
-if (nng_msg_alloc(&m, 1024) != 0) {
- // handle error
-}
-while ((val64 = next_datum()) != 0) P
- if (nng_msg_append_u64(m, val64) != 0) {
+ if (nng_msg_alloc(&m, 1024) != 0) {
// handle error
}
-}
+ while ((val64 = next_datum()) != 0) P
+ if (nng_msg_append_u64(m, val64) != 0) {
+ // handle error
+ }
+ }
```
## See Also