pike.git / src / dynamic_load.c

version» Context lines:

pike.git/src/dynamic_load.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: dynamic_load.c,v 1.69 2003/04/07 17:28:55 nilsson Exp $ + || $Id: dynamic_load.c,v 1.70 2003/06/06 14:30:02 grubba Exp $   */      #ifdef TESTING   #define NO_PIKE_INCLUDES   #define CREATE_MAIN   #define NO_PIKE_GUTS   #endif      #ifndef NO_PIKE_INCLUDES   # include "global.h"
pike.git/src/dynamic_load.c:17:   # include "constants.h"   # include "pike_error.h"   # include "module.h"   # include "stralloc.h"   # include "pike_macros.h"   # include "main.h"   # include "constants.h"   # include "language.h"   # include "lex.h"    - RCSID("$Id: dynamic_load.c,v 1.69 2003/04/07 17:28:55 nilsson Exp $"); + RCSID("$Id: dynamic_load.c,v 1.70 2003/06/06 14:30:02 grubba Exp $");      #else /* TESTING */      #include <stdio.h>      #endif /* !TESTING */      #ifdef HAVE_ERRNO_H   #include <errno.h>   #endif /* HAVE_ERRNO_H */
pike.git/src/dynamic_load.c:343:   #endif /* NO_CAST_TO_FUN */      struct compilation_save   {    struct lex lex;    int compilation_depth;   };      static void cleanup_compilation(struct compilation_save *save)   { -  free_program(end_program()); +  struct program *p = end_program(); +  if (p) { +  free_program(p); +  }    free_string(lex.current_file);    compilation_depth = save->compilation_depth;    lex = save->lex;   }      /*! @decl program load_module(string module_name)    *!    *! Load a binary module.    *!    *! This function loads a module written in C or some other language
pike.git/src/dynamic_load.c:485: Inside #if defined(PIKE_DEBUG)
   UNSET_ONERROR(err);   #ifdef PIKE_DEBUG    if(Pike_sp != save_sp)    Pike_fatal("load_module(%s) left %ld droppings on stack!\n",    module_name,    PTRDIFF_T_TO_LONG(Pike_sp - save_sp));    }   #endif       pop_n_elems(args); -  push_program(end_program()); +  { +  struct program *p = end_program();    free_string(lex.current_file);    compilation_depth = save.compilation_depth;    lex = save.lex; -  +  if (p) { +  push_program(p);    add_ref(new_module->module_prog = Pike_sp[-1].u.program); -  +  } else { +  /* Initialization failed. */ +  new_module->exit(); +  dlclose(module); +  dynamic_module_list = new_module->next; +  free(new_module); +  if (strlen(module_name) < 1024) { +  Pike_error("Failed to initialize dynamic module \"%s\".\n", module_name); +  } else { +  Pike_error("Failed to initialize dynamic module.\n");    } -  +  } +  } + }      #endif /* USE_DYNAMIC_MODULES */         void init_dynamic_load(void)   {   #ifdef USE_DYNAMIC_MODULES    if (dlinit()) {       /* function(string:program) */