custom tree model, iters, and memory management



While working on a custom tree model (thanks to Tim-Philipp Müller for the tutorial), I needed more pointers in my iter structure than the user_data, user_data2, and user_data3. So I defined a new structure and stored that in user_data. For the model's _get_iter(), _iter_children(), _iter_parent(), iter_nth_child() methods, if the "output" iter's user_data is NULL, a new one of these "extra pointers structures" gets allocated. At the moment, all of these allocations get also referenced in a GSList in the custom model, and freed when the model is finalized. While this does work ok, it feels strange. Any thoughts? Some light analysis shows the treeview doesn't use that many iters, so maybe this is fine?





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]