diff options
| author | Tyge Løvset <[email protected]> | 2020-12-09 12:05:49 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-09 12:05:49 +0100 |
| commit | e3d6b9b3cb42a0fc066572e9aefb41b5cf45dc2c (patch) | |
| tree | 037dbcbfdfe20da8bfef3abdb5a207e19e6f1ea7 /docs/cptr_api.md | |
| parent | 30a400f71df76c077c97590b7a60daba98bef396 (diff) | |
| download | STC-modified-e3d6b9b3cb42a0fc066572e9aefb41b5cf45dc2c.tar.gz STC-modified-e3d6b9b3cb42a0fc066572e9aefb41b5cf45dc2c.zip | |
Update cptr_api.md
Diffstat (limited to 'docs/cptr_api.md')
| -rw-r--r-- | docs/cptr_api.md | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/docs/cptr_api.md b/docs/cptr_api.md index eec9c899..6b1b7d0c 100644 --- a/docs/cptr_api.md +++ b/docs/cptr_api.md @@ -2,7 +2,7 @@ This describes the API of the type **cuptr** and the shared pointer type **csptr**. The **cuptr** is meant to be used like a c++ std::unique_ptr, while **csptr** is similar to c++ std::shared_ptr. -The **cuptr** type is meant to be used as elements of containers, because the pointed to elements will automatically be deleted when the container is deleted. On its own, it offers little over regular pointers. **csptr** however, is useful when you want to track and delete the last usage of a pointer. **csptr** uses atomic usage counting, via the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. +The **cuptr** type can be used as elements of containers, so the pointed-to elements are automatically deleted when the container is deleted. On its own, it offers little over regular pointers. **csptr** however is useful for tracking and deleting the last usage of a pointer. **csptr** has thread-safe atomic use count, via the *csptr_X_share(sp)* and *csptr_X_del(&sp)* methods. ## Declaration @@ -63,7 +63,7 @@ int csptr_pointer_compare(csptr_X_value_t* x, csptr_X_value_t* y ``` ## Example -This shows three maps with struct Person as the mapped type in different ways, map1 with Person value, map2 with bare pointer to Person, and map3 with a shared pointer to Person. +This shows 3 maps with struct Person as the mapped type in different ways, map1 with Person value, map2 with cuptr to Person, and map3 with a csptr to Person. A 4th option would be to have raw pointers to Person as mapped values, which would not be deleted on map destruction. Should be used if the mapped values are owned by a different container. ```c #include <stc/cptr.h> #include <stc/cmap.h> |
