Validate ref count opt-in in bt_ref_get
[babeltrace.git] / include / babeltrace / ref-internal.h
index 8578de97b2ec1808eded8e9887961c1e3e7f4644..3a8b39f4136139807ba6c207b77725fe8554a499 100644 (file)
@@ -50,9 +50,12 @@ static inline
 void bt_ref_get(struct bt_ref *ref)
 {
        assert(ref);
-       ref->count++;
-       /* Overflow check. */
-       assert(ref->count);
+       if (ref->release) {
+               /* Object has opted-in reference counting. */
+               ref->count++;
+               /* Overflow check. */
+               assert(ref->count);
+       }
 }
 
 static inline
This page took 0.036578 seconds and 4 git commands to generate.