[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gEDA: Patrick & Stuart's refactoring of s_project_alloc
Hi guys & hi Patrick --
Patrick & I are working on the same section of code in
libgeda/noweb/s_project.nw and gschem/noweb/x_window.nw. Since
something broke yesterday, I thought I'd report what happened here.
I recently made changes to the RC file system so that an RC file for a
newly-opened schematic would be read in if the RC file had not been
read in before. I keep track of which RC files have been opened
using "GList pr_current->RC_list", defined in
libgeda/include/struct.h. It needs to be initialized to NULL before
it is tested in g_rc_parse_general.
The way I have set up gEDA to initialize is this:
1. Call s_project_alloc (or x_window_alloc). This calls malloc to
allocate the space required for the TOPLEVEL structure. It also sets
pr_current->RC_list = NULL.
2. Call the guile fcns which register the RC files. It is important
that pr_current->RC_list be NULL when this fcn is called for the first
time, otherwise the prog can segfault.
3. Call s_project_fill_out (or x_window_fill_out) to fill out the
rest of the TOPLEVEL structure.
Patrick, when you cleaned up the code, you moved the
pr_current->RC_list = NULL assignment to stage 3. I belive this is
why Christoph was getting a segfault.
Moving forward, I am open to other ways to acheive my goals. I am not
wedded to my way of initializing gEDA; I welcome Patrick's (or anybody
else's) changes to this. Indeed, I am very happy with Patrick's code
cleanup -- his skills are valuable & his changes were good.
I also recognize that it is cleaner conceptually to only malloc the
space for TOPLEVEL in the *_alloc fcn. However, we need to make sure
that *->RC_list == NULL before step 2 is executed. Besides my method
of assigning it in step 1, is there a better way to do this? Maybe
using calloc?
Stuart