summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/stc/carc.h8
-rw-r--r--include/stc/cbox.h14
2 files changed, 15 insertions, 7 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 7f7789ab..f14fdd65 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -157,17 +157,17 @@ STC_INLINE _cx_self _cx_memb(_clone)(_cx_self ptr) {
return ptr;
}
-STC_INLINE void _cx_memb(_copy)(_cx_self* self, _cx_self ptr) {
+STC_INLINE void _cx_memb(_assign)(_cx_self* self, _cx_self ptr) {
if (ptr.use_count)
_i_atomic_inc(ptr.use_count);
_cx_memb(_drop)(self);
*self = ptr;
}
-STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self ptr) {
- if (self->get != ptr.get)
+STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self unowned) {
+ if (self->get != unowned.get)
_cx_memb(_drop)(self);
- *self = ptr;
+ *self = unowned;
}
#ifndef i_no_cmp
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index a0966fcc..b8a61375 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -142,10 +142,18 @@ STC_INLINE _cx_self _cx_memb(_from)(_cx_value val)
}
#endif // !i_no_clone
-STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self other) {
- if (other.get != self->get)
+STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self unowned) {
+ if (unowned.get != self->get)
_cx_memb(_drop)(self);
- *self = other;
+ *self = unowned;
+}
+/* transfer ownership; set dying to NULL */
+STC_INLINE void _cx_memb(_assign)(_cx_self* self, _cx_self* dying) {
+ if (dying->get == self->get)
+ return;
+ _cx_memb(_drop)(self);
+ *self = *dying;
+ dying->get = NULL;
}
#ifndef i_no_cmp