summaryrefslogtreecommitdiffhomepage
path: root/examples/new_sptr.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-12-22 12:35:36 +0100
committerTyge Løvset <[email protected]>2021-12-22 12:35:36 +0100
commit79c83eba7933f49e766dbeb85f9c40ee17e06edf (patch)
treee43a84d18b79956a8e22b9403358811b6865f344 /examples/new_sptr.c
parent7a30e2853792870a1d85087861e46a1ae1ca6b0e (diff)
downloadSTC-modified-79c83eba7933f49e766dbeb85f9c40ee17e06edf.tar.gz
STC-modified-79c83eba7933f49e766dbeb85f9c40ee17e06edf.zip
Renamed csptr to carc. i_key/val_ref renamed to i_key/val_sptr. Change inspired by Rust Arc/Rc. cbox name is taken from Rust Box type.
Diffstat (limited to 'examples/new_sptr.c')
-rw-r--r--examples/new_sptr.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/new_sptr.c b/examples/new_sptr.c
index ce31478e..045eef77 100644
--- a/examples/new_sptr.c
+++ b/examples/new_sptr.c
@@ -14,29 +14,29 @@ void Person_drop(Person* p) {
#define i_drop Person_drop
#define i_opt c_no_cmp
#define i_tag person
-#include <stc/csptr.h>
+#include <stc/carc.h>
// ...
#define i_val int
#define i_drop(x) printf("drop: %d\n", *(x))
-#include <stc/csptr.h>
+#include <stc/carc.h>
-#define i_val_bind csptr_int
+#define i_val_bind carc_int
#define i_tag iptr
#include <stc/cstack.h>
int main(void) {
- c_autovar (csptr_person p = csptr_person_from(Person_new("John", "Smiths")), csptr_person_drop(&p))
- c_autovar (csptr_person q = csptr_person_clone(p), csptr_person_drop(&q)) // share the pointer
+ c_autovar (carc_person p = carc_person_from(Person_new("John", "Smiths")), carc_person_drop(&p))
+ c_autovar (carc_person q = carc_person_clone(p), carc_person_drop(&q)) // share the pointer
{
printf("%s %s. uses: %lu\n", q.get->name.str, q.get->last.str, *q.use_count);
}
c_auto (cstack_iptr, stk) {
- cstack_iptr_push(&stk, csptr_int_from(10));
- cstack_iptr_push(&stk, csptr_int_from(20));
- cstack_iptr_push(&stk, csptr_int_from(30));
+ cstack_iptr_push(&stk, carc_int_from(10));
+ cstack_iptr_push(&stk, carc_int_from(20));
+ cstack_iptr_push(&stk, carc_int_from(30));
cstack_iptr_emplace(&stk, *cstack_iptr_top(&stk));
cstack_iptr_emplace(&stk, *cstack_iptr_begin(&stk).ref);