SlickEdit Product Discussion > Slick-C® Macro Programming

Question about slick C

(1/1)

Graeme:
Related to my question here
https://community.slickedit.com/index.php/topic,18344.msg72392.html#msg72392

I have a doubly linked list handler and I use linked lists in a variety of places in my macros.  This seems to mean that I have a number of "dlist" objects in my state file

e.g.

--- Code: ---struct dlist_node {
   int s_next;
   int s_prev;
   typeless s_data;
};

struct dlist {
   int s_head;   
   int s_tail;
   int max_nodes;
   boolean overwrite_f;
   dlist_node nodes[];
   int free_head;
   int free_count;
};

static dlist      retrace_cursor_list;
static dlist      retrace_modified_lines_list;

--- End code ---

So now I want to add a new member to the dlist struct
bool modified;
If I add this member, then reload the module, will this cause my macro code to crash because the memory for the dlist objects in the state file doesn't match the new struct?

If so, how do I handle this?

I suspect slick C has a way of handling this but if it does, then why am I getting crashes??

I would have expected that if I delete the state file and all the .ex files and rebuild everything, the problem should go away  - but it doesn't seem to.  I'm unable to add a new data member to the dlist struct without getting crashes.   Correction, this does seem to resolve it  - but this is not really a solution for other people who are using my xretrace macro.

Graeme:
It seems that any modules that use my linked list handler have to be unloaded before changing and reloading DLinkList.e.  Now I have to figure out how to arrange that for people who are using xretrace already.  Possibly I could ask people to manually unload.

Dennis:
In our macros, we frequently use an _exit_[module_name]() hook to initialize static module-level globals to null so that they are not saved in the state file. 

Example:


--- Code: ---void _exit_errfile()
{
   if (_file_eq(COMPILE_ERROR_FILE,_temp_path():+"vserr.":+getpid())) {
      delete_file(COMPILE_ERROR_FILE);
   }
   gAllExpressions._makeempty();
   gLangExpressions._makeempty();
   gExclusionExpressions._makeempty();
}

--- End code ---

Graeme:
Thanks, that's useful.  I have some lists I would like to get out of the state file.

Navigation

[0] Message Index

Go to full version