Fix leak in render macro

This commit is contained in:
Jonathan Kelley committed 2024-01-08 19:20:31 -08:00
1 parent 0a35b5a670
commit 44a27bf8a3
9 files changed
+197 -114

No files matched your search

+28 -7
View File
@@ -171,15 +171,27 @@ fn create_random_dynamic_node(cx: &ScopeState, depth: usize) -> DynamicNode {
match rand::random::<u8>() % range {
0 => DynamicNode::Placeholder(Default::default()),
1 => cx.make_node((0..(rand::random::<u8>() % 5)).map(|_| {
VNode::new(
// <<<<<<< HEAD
// VNode::new(
// None,
// Template {
// =======
cx.vnode(
None,
Template {
Default::default(),
Cell::new(Template {
// >>>>>>> 9fe172e9 (Fix leak in render macro)
name: concat!(file!(), ":", line!(), ":", column!(), ":0"),
roots: &[TemplateNode::Dynamic { id: 0 }],
node_paths: &[&[0]],
attr_paths: &[],
},
bumpalo::collections::Vec::new_in(cx.bump()),
// <<<<<<< HEAD
// },
// bumpalo::collections::Vec::new_in(cx.bump()),
// =======
}),
bumpalo::collections::Vec::new_in(cx.bump()).into(),
// >>>>>>> 9fe172e9 (Fix leak in render macro)
cx.bump().alloc([cx.component(
create_random_element,
DepthProps { depth, root: false },
@@ -273,10 +285,19 @@ fn create_random_element(cx: Scope<DepthProps>) -> Element {
)
.into_boxed_str(),
));
let node = VNode::new(
// <<<<<<< HEAD
// let node = VNode::new(
// None,
// template,
// bumpalo::collections::Vec::new_in(cx.bump()),
// =======
// println!("{template:#?}");
let node = cx.vnode(
None,
template,
bumpalo::collections::Vec::new_in(cx.bump()),
None,
Cell::new(template),
bumpalo::collections::Vec::new_in(cx.bump()).into(),
// >>>>>>> 9fe172e9 (Fix leak in render macro)
{
let dynamic_nodes: Vec<_> = dynamic_node_types
.iter()