* files when the interpreter exits
*/
+#ifndef START_MY_CXT /* Some IDEs try compiling this standalone. */
+# include "EXTERN.h"
+# include "perl.h"
+# include "XSUB.h"
+#endif
+
#ifndef XS_VERSION
# define XS_VERSION "0"
#endif
#define MY_CXT_KEY "DynaLoader::_guts" XS_VERSION
typedef struct {
- char * x_dl_last_error; /* pointer to allocated memory for
+ SV* x_dl_last_error; /* pointer to allocated memory for
last error message */
int x_dl_nonlazy; /* flag for immediate rather than lazy
linking (spots unresolved symbol) */
START_MY_CXT
-#define dl_last_error (MY_CXT.x_dl_last_error)
+#define dl_last_error (SvPVX(MY_CXT.x_dl_last_error))
#define dl_nonlazy (MY_CXT.x_dl_nonlazy)
#ifdef DL_LOADONCEONLY
#define dl_loaded_files (MY_CXT.x_dl_loaded_files)
AV *dl_librefs;
SV *dl_libref;
- if ((sub = get_cv("DynaLoader::dl_unload_file", FALSE)) != NULL) {
- dl_librefs = get_av("DynaLoader::dl_librefs", FALSE);
+ if ((sub = get_cvs("DynaLoader::dl_unload_file", 0)) != NULL) {
+ dl_librefs = get_av("DynaLoader::dl_librefs", 0);
while ((dl_libref = av_pop(dl_librefs)) != &PL_sv_undef) {
dSP;
ENTER;
char *perl_dl_nonlazy;
MY_CXT_INIT;
- dl_last_error = NULL;
+ MY_CXT.x_dl_last_error = newSVpvn("", 0);
dl_nonlazy = 0;
#ifdef DL_LOADONCEONLY
- dl_loaded_files = Nullhv;
+ dl_loaded_files = NULL;
#endif
#ifdef DEBUGGING
{
}
+#ifndef SYMBIAN
/* SaveError() takes printf style args and saves the result in dl_last_error */
static void
-SaveError(pTHX_ char* pat, ...)
+SaveError(pTHX_ const char* pat, ...)
{
dMY_CXT;
va_list args;
SV *msv;
- char *message;
+ const char *message;
STRLEN len;
/* This code is based on croak/warn, see mess() in util.c */
message = SvPV(msv,len);
len++; /* include terminating null char */
- /* Allocate some memory for the error message */
- if (dl_last_error)
- dl_last_error = (char*)saferealloc(dl_last_error, len);
- else
- dl_last_error = (char*)safemalloc(len);
-
/* Copy message into dl_last_error (including terminating null char) */
- strncpy(dl_last_error, message, len) ;
+ sv_setpvn(MY_CXT.x_dl_last_error, message, len) ;
DLDEBUG(2,PerlIO_printf(Perl_debug_log, "DynaLoader: stored error msg '%s'\n",dl_last_error));
}
+#endif