Branch: Tag:

2002-03-10

2002-03-10 03:14:46 by Martin Stjernholm <mast@lysator.liu.se>

Handle loading of the same module repeatedly.

Rev: src/dynamic_load.c:1.60

17:   # include "language.h"   # include "lex.h"    - RCSID("$Id: dynamic_load.c,v 1.59 2002/01/31 17:52:14 marcus Exp $"); + RCSID("$Id: dynamic_load.c,v 1.60 2002/03/10 03:14:46 mast Exp $");      #else /* TESTING */   
312: Inside #if defined(USE_DYNAMIC_MODULES)
  {    struct module_list * next;    void *module; +  struct program *module_prog;    modfun init, exit;   };   
348:    lex = save->lex;   }    - /*! @decl int load_module(string module_name) + /*! @decl program load_module(string module_name)    *!    *! Load a binary module.    *!
403:    }    }    +  { +  struct module_list *mp; +  for (mp = dynamic_module_list; mp; mp = mp->next) +  if (mp->module == module && mp->module_prog) { +  ref_push_program(mp->module_prog); +  return; +  } +  } +     init = CAST_TO_FUN(dlsym(module, "pike_module_init"));    if (!init) {    init = CAST_TO_FUN(dlsym(module, "_pike_module_init"));
427:    new_module->next=dynamic_module_list;    dynamic_module_list=new_module;    new_module->module=module; +  new_module->module_prog = NULL;    new_module->init=init;    new_module->exit=exit;   
458:    free_string(lex.current_file);    compilation_depth = save.compilation_depth;    lex = save.lex; +  add_ref(new_module->module_prog = sp[-1].u.program);   }      #endif /* USE_DYNAMIC_MODULES */
489: Inside #if defined(USE_DYNAMIC_MODULES)
   else    (*tmp->exit)();    UNSETJMP(recovery); +  free_program(tmp->module_prog); +  tmp->module_prog = NULL;    }   #endif   }
504: Inside #if defined(USE_DYNAMIC_MODULES) and #if undefined(DEBUG_MALLOC)
  #ifndef DEBUG_MALLOC    dlclose(tmp->module);   #endif +  if (tmp->module_prog) free_program(tmp->module_prog);    free((char *)tmp);    }   #endif