aboutsummaryrefslogtreecommitdiff
path: root/docs/ref/api/memory.md
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-10-22 21:16:23 -0700
committerGarrett D'Amore <garrett@damore.org>2024-10-22 21:16:23 -0700
commitbeca672e36109bf8f49c260257882fc3e9cea034 (patch)
treec8b10b75a6173090fdf1a2d0ab1f34595abe5995 /docs/ref/api/memory.md
parent97e113a7027afa9b9c11580d02772b5096c6c5a4 (diff)
downloadnng-beca672e36109bf8f49c260257882fc3e9cea034.tar.gz
nng-beca672e36109bf8f49c260257882fc3e9cea034.tar.bz2
nng-beca672e36109bf8f49c260257882fc3e9cea034.zip
docs: master cross-reference table
Diffstat (limited to 'docs/ref/api/memory.md')
-rw-r--r--docs/ref/api/memory.md24
1 files changed, 10 insertions, 14 deletions
diff --git a/docs/ref/api/memory.md b/docs/ref/api/memory.md
index fb7ec18e..c5ecb23a 100644
--- a/docs/ref/api/memory.md
+++ b/docs/ref/api/memory.md
@@ -17,11 +17,11 @@ The memory will be 64-bit aligned.
Note that the memory may have random data in it, just like with `malloc`.
If memory cannot be allocated for any reason, then `NULL` will be returned.
-Applications that experience this should treat this like `NNG_ENOMEM`.
+Applications that experience this should treat this like [`NNG_ENOMEM`].
Memory returned by `nng_alloc` can be used to hold message buffers, in which
-case it can be directly passed to [`nng_send`][nng_send] using the flag `NNG_FLAG_ALLOC`.
-Alternatively, it can be freed when no longer needed using [`nng_free`][nng_free].
+case it can be directly passed to [`nng_send`] using the flag `NNG_FLAG_ALLOC`.
+Alternatively, it can be freed when no longer needed using [`nng_free`].
> [!IMPORTANT]
> Do not use the system `free` function (or the C++ `delete` operator) to release this memory.
@@ -34,10 +34,10 @@ Alternatively, it can be freed when no longer needed using [`nng_free`][nng_free
void nng_free(void *ptr, size_t size);
```
-The {{i:`nng_free`}} function deallocates memory previously allocated by [`nng_alloc`][nng_alloc].
+The {{i:`nng_free`}} function deallocates memory previously allocated by [`nng_alloc`].
The _size_ argument must exactly match the _size_ argument that was supplied to
-`nng_alloc` when the memory was allocated.
+[`nng_alloc`] when the memory was allocated.
## Duplicate String
@@ -47,14 +47,14 @@ char *nng_strdup(const char *src);
The {{i:`nng_strdup`}} duplicates the string _src_ and returns it.
-This is logically equivalent to using [`nng_alloc`][nng_alloc]
+This is logically equivalent to using [`nng_alloc`]
to allocate a region of memory of `strlen(s) + 1` bytes, and then
using `strcpy` to copy the string into the destination before
returning it.
The returned string should be deallocated with
-[`nng_strfree`][nng_strfree], or may be deallocated using the
-[`nng_free`][nng_free] using the length of the returned string plus
+[`nng_strfree`], or may be deallocated using the
+[`nng_free`] using the length of the returned string plus
one (for the `NUL` terminating byte).
## Free String
@@ -64,12 +64,8 @@ void nng_strfree(char *str);
```
The {{i:`nng_strfree`}} function is a convenience function that
-can be used to deallocate strings allocated with [`nng_strdup`][nng_strdup].
+can be used to deallocate strings allocated with [`nng_strdup`].
It is effectively the same as `nng_free(strlen(str) + 1)`.
-[nng_alloc]: #allocate-memory
-[nng_free]: #deallocate-memory
-[nng_strdup]: #duplicate-string
-[nng_strfree]: #free-string
-[nng_send]: TODO.md
+{{#include ../xref.md}}