|
From: Ethan A M. <merritt@u.washington.edu> - 2007-04-09 03:27:48
|
On Sunday 08 April 2007 19:46, Daniel J Sebald wrote: > Ethan A Merritt wrote: > > > > I have prepared and attached a patch that switches the calls to cp_free() > > from late in the routine to the front (where the above comment now sits). > > The comment seems to warn this will break things if there is an inconvenient > > int_error() from the plot command. > > Well, the patch could probably be moved into CVS right away as it seems like a > memory leak and what you've done is a fairly safe way of programming. > It's safe right now because there is no conditional and memory is always freed > at that point if some was assigned. I think you are missing the worrisome point. The routine cp_free() works its way through a linked list of plots, freeing all dynamically allocated space as it goes. The comment warns that this may fail if there was a call to int_error() while one of those dynamically allocated plot structures was in the process of being filled in. That would hypothetically leave invalid links in the linked list, or struct entries that are supposedly pointers but contain random garbage. This really shouldn't happen if everything is initialized in the correct order, but the comment suggests that may not be the case. > But the issue with regard to replotting and retaining the plot structure with > data (which isn't to be reloaded) is just what the above message says. If there > is a failure along the way, the plot pointer is valid, but the information in > the structure may not be valid. Exactly. But we should try to insure that cannot happen. -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle 98195-7742 |