xforms-development
[Top][All Lists]
Advanced

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

Re: [XForms] Bug?


From: Jens Thoms Toerring
Subject: Re: [XForms] Bug?
Date: Mon, 5 Jan 2015 10:45:13 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Jon,

    I just had a bit of a look at the flimage code
and run a few tests. As far as I can see all files
get closed again, so I don't think it's related to
running out of file handles (at least I could open
more than 10000 images and nothing bad happened).
But there's something else I noticed:

> image=flimage_load("/tmp/cam1m.jpg");
> if (image)
> {
>         flimage_display( image, FL_ObjWin( fd_hc_legacycams->camview1 ) );
>         flimage_free(image);
>         flimage_close(image);

Here you're doing something forbidden: flimage_free() does
already closes the file and also releases all memory for
the structure pointed to by 'image'. Thus after calling
flimage_free() you're not allowed to use that pointer
anymore, also not for flimage_close() since it now points
to memory you don't "own" (and may have become reused for
something else.

If your intention was to close the file but still be able
to use the image (in memory) call flimage_close() - this
only closes file handles. Call flimage_free() only when
you're done with the image in memory. If you don't call
flimage_close() flimage_free() will close the files for 
you automatically, so flimage_close() is actually only
needed for cases where you load a lot of images that you
want to keep in memory while avoiding to run out of file
descriptors. Otherwise calling it is redundant.

                     Best regards, Jens
-- 
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]