Skip to content

Commit ace7db4

Browse files
committed
fix nil-cases of cfg insertion; fix incorrect root setting in cfg deep copy
1 parent 1b52100 commit ace7db4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/raddbg/raddbg_core.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,14 @@ rd_cfg_deep_copy(RD_Cfg *src_root)
635635
for(RD_Cfg *src = src_root; src != &rd_nil_cfg; src = rec.next)
636636
{
637637
RD_Cfg *dst = rd_cfg_new(dst_parent, src->string);
638+
if(dst_root == &rd_nil_cfg)
639+
{
640+
dst_root = dst;
641+
}
638642
rec = rd_cfg_rec__depth_first(src_root, src);
639643
if(rec.push_count > 0)
640644
{
641645
dst_parent = dst;
642-
if(dst_root == &rd_nil_cfg)
643-
{
644-
dst_root = dst;
645-
}
646646
}
647647
else for(S32 pop_idx = 0; pop_idx < rec.pop_count; pop_idx += 1)
648648
{
@@ -677,8 +677,11 @@ rd_cfg_equip_stringf(RD_Cfg *cfg, char *fmt, ...)
677677
internal void
678678
rd_cfg_insert_child(RD_Cfg *parent, RD_Cfg *prev_child, RD_Cfg *new_child)
679679
{
680-
DLLInsert_NPZ(&rd_nil_cfg, parent->first, parent->last, prev_child, new_child, next, prev);
681-
new_child->parent = parent;
680+
if(parent != &rd_nil_cfg)
681+
{
682+
DLLInsert_NPZ(&rd_nil_cfg, parent->first, parent->last, prev_child, new_child, next, prev);
683+
new_child->parent = parent;
684+
}
682685
}
683686

684687
internal void

0 commit comments

Comments
 (0)