This commit extends BagManager with destroy method. This change allows
users to safely destruct bags allocated via Bagmanager.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
public:
Bag *create(uint32_t size);
+public:
+ // @brief Destroy (= deallocate) a Bag entity
+ //
+ // NOTE A Bag SHOULD BE detached from IR before destruction
+ void destroy(Bag *b);
+
private:
PtrLink<Bag, BagInfo> *const _link;
};
return take(std::move(bag));
}
+void BagManager::destroy(Bag *b) { release(b); }
+
} // namespace coco
ASSERT_EQ(info->size(), 3);
}
+
+TEST(IR_BAG_MANAGER, destruct)
+{
+ coco::PtrLink<coco::Bag, coco::BagInfo> bag_link;
+ coco::BagManager mgr{&bag_link};
+
+ auto b = mgr.create(3);
+ mgr.destroy(b);
+
+ ASSERT_EQ(mgr.size(), 0);
+}