Author Topic: Question about slick C  (Read 2947 times)

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Question about slick C
« on: August 23, 2021, 11:04:18 AM »
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: [Select]
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;

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.
« Last Edit: August 23, 2021, 11:34:14 AM by Graeme »

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Question about slick C
« Reply #1 on: August 23, 2021, 11:55:41 PM »
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

  • Senior Community Member
  • Posts: 3960
  • Hero Points: 517
Re: Question about slick C
« Reply #2 on: August 27, 2021, 02:41:40 PM »
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: [Select]
void _exit_errfile()
{
   if (_file_eq(COMPILE_ERROR_FILE,_temp_path():+"vserr.":+getpid())) {
      delete_file(COMPILE_ERROR_FILE);
   }
   gAllExpressions._makeempty();
   gLangExpressions._makeempty();
   gExclusionExpressions._makeempty();
}

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Question about slick C
« Reply #3 on: August 28, 2021, 10:56:02 AM »
Thanks, that's useful.  I have some lists I would like to get out of the state file.