This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
GvFILE() cannot be a pointer to the memory owned by the COP, because
[perl5.git] / ext / ByteLoader / bytecode.h
index 50198ec..9df93ff 100644 (file)
@@ -376,6 +376,17 @@ typedef char *pvindex;
                SvREFCNT_dec(w);                                        \
            }                                                           \
        } STMT_END
+#define BSET_gp_file(gv, file) \
+       STMT_START {                                                    \
+           STRLEN len = strlen(file);                                  \
+           U32 hash;                                                   \
+           PERL_HASH(hash, file, len);                                 \
+           if(GvFILE_HEK(gv)) {                                        \
+               Perl_unshare_hek(aTHX_ GvFILE_HEK(gv));                 \
+           }                                                           \
+           GvGP(gv)->gp_file_hek = share_hek(file, len, hash);         \
+           Safefree(file);                                             \
+       } STMT_END
 
 /* NOTE: the bytecode header only sanity-checks the bytecode. If a script cares about
  * what version of Perl it's being called under, it should do a 'use 5.006_001' or