Re: [AD] gfxtest locks up with 4.0.0 + watcom

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> Damn, you're right. I wonder why I thought GetVideoModeInfo()
> allocated that memory in the first place. Attached is an UNTESTED
> patch which aims to fix several potential memory leaks and fix this
> particular problem.

The patch should fix the problem. However, I personnaly don't like it very
much because there is too much duplicated code: in order to avoid memory
leaks, you wrote many times the same if (foo) free(foo). Moreover, you
forgot to do the same for vbe_was_off, which will add 4 more duplicated
lines.

The clean way to write error handling code in a driver initialisation
function is IMHO:

if (something_went_wrong)
   goto Error;

Error:
if (foo1)
   free(foo1)

if (foo2)
   free(foo2)

--
Eric Botcazou
ebotcazou@xxxxxxxxxx



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/