From: Dennis S. <sy...@yo...> - 2004-11-22 16:10:10
|
On Sun, 2004-11-21 at 22:38 +0200, Vitaly V. Bursov wrote: > Hi! :) HI!! where have you been!, I'm so glad to see that you're back !!! *YAY!* > lvdisplay now supports multiple screens :) Neat! :) > ======= example/main.c > VisInput *input = visual_input_new("alsa"); > [snip] > visual_bin_connect(bin, actor, input); > visual_bin_connect(bin2, actor2, input); > [snip] > lvdisplay_finalize(v); > lvdisplay_finalize(v2); > ======== > yup, "input" gets free()'d 2 times. How we're going to fix it? Ai, I see the problem! > a. forbid such kind of code. Add input->is_used field to debug it. > b. add refcounting to input and alike structures and free it accordingly > > I think b. is nice here. Because we have a reentrant design, plugin > can be used multiple times.... or not? I agree, we should introduce refcounting. I've got to add something to this. What about introducing a VisObject structure, from which every structure can 'inheritent' by making sure it's allocated in the top of the struct like I did in VisUI and do ref counting things on a global scale, something like visual_object_ref, visual_object_unref etc... We could introduce cast macros so you get something like VisInput *input = blahblah; visual_object_unref (VISUAL_OBJECT (input)); to decrease the ref count. What do you think ?, and are there things I should keep in mind, I never implemented ref counting before, but I understand the idea... > and BTW, why not to move -O3 flag to configure scripts and use it only > when --enable-debug is not passed? Please go ahead and do this, if you'd like :) Cheers, Dennis |