[Top][All Lists]

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

Re: [XForms] fl_set_xyplot_alphaxtics and memory allocation

From: Jens Thoms Toerring
Subject: Re: [XForms] fl_set_xyplot_alphaxtics and memory allocation
Date: Wed, 28 Sep 2011 21:57:10 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Al,

On Wed, Sep 28, 2011 at 08:26:54PM +0200, alessandro basili wrote:
> my team is using xforms-1.0 and we have an apparently simple problem
> with xyplot and specifically with fl_set_xyplot_alphaxtics.
> Our applications are displaying data vs time and we use an fl_timeout
> callback to read the files where data are stored.
> Since we need to display the tics with special formats, we decided to
> use the "alphatics" functions available in the library.
> Unfortunately we noticed that every time we call the function there's a
> memory allocation (performed by fl_strdup) even if the memory has
> already been allocated.
> This behavior causes an increase of the memory usage which affects the
> long term usage of the application.
> To overcome this problem we used the following trick:
> fl_set_xyplot_xtics();        //deallocates axtic with free_atic
> fl_set_xyplot_alphaxtics();   //allocates axtic with fl_strdup
> in this way we can "control" the usage of the memory.
> Unfortunately we can neither access to the FL_XYPLOT_SPEC structure
> directly since it is privately defined (and I think is a good choice!),
> nor call free_axtic directly since is static, but I believe there should
> be a better way to accomplish the very same result without the need to
> call a function that we don't need.

You're absolutely right, this is one of the bugs in that function
- it should call free_atics() before allocating new strings (and
at least the first elements of both the sp-axtic and sp->aytic
array must then be initialized with NULL). Unfortunately, all I
can do is fix the bug in the newest version. I guess it will be
available as a pre-release version within the next few days.

> Hope someone can suggest a better solution.

Without you're moving to a newer version I don't know any better
way, sorry. Your fix of calling fl_set_xyplot_xtics() to force the
deallocation to happen seems to be the simplest way at the moment.

Would you be prepared to give a new version a try? xforms-1.0 is
really, really old (at least 9 years) and I am in the process of
releasing version 1.2 hopefully soon, just trying to get rid of
a few known bugs - the one you've found has become one of them
                            Best regards, Jens
  \   Jens Thoms Toerring  ________      address@hidden
   \_______________________________      http://toerring.de

reply via email to

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