Some small tweak to how we load XS, most notably shutting up
[gitmo/Class-MOP.git] / MOP.xs
diff --git a/MOP.xs b/MOP.xs
index f86e04a..51a76da 100644 (file)
--- a/MOP.xs
+++ b/MOP.xs
@@ -3,6 +3,7 @@
 #include "perl.h"
 #include "XSUB.h"
 
+#define NEED_sv_2pv_flags
 #define NEED_sv_2pv_nolen
 #include "ppport.h"
 
@@ -99,16 +100,13 @@ get_all_package_symbols(self, ...)
             if ( type_filter && SvPOK(type_filter) ) {
                 const char *const type = SvPV_nolen(type_filter);
 
-
                 while ((he = hv_iternext(stash))) {
                     SV *const gv = HeVAL(he);
                     SV *sv;
-                    char *package = HvNAME(stash);
-                    STRLEN pkglen = strlen(package);
                     char *key;
                     STRLEN keylen;
-                    char *fq;
-                    STRLEN fqlen;
+                    char *package;
+                    SV *fq;
 
                     switch( SvTYPE(gv) ) {
                         case SVt_PVGV:
@@ -124,12 +122,13 @@ get_all_package_symbols(self, ...)
                             break;
                         case SVt_RV:
                             /* BAH! constants are horrible */
+
+                            /* we don't really care about the length,
+                               but that's the API */
                             key = HePV(he, keylen);
-                            fqlen = pkglen + keylen + 3;
-                            fq = (char *)alloca(fqlen);
-                            snprintf(fq, fqlen, "%s::%s", package, key);
-                            sv = (SV*)get_cv(fq, 0);
-                            sv_2mortal(sv);
+                            package = HvNAME(stash);
+                            fq = newSVpvf("%s::%s", package, key);
+                            sv = sv_2mortal((SV*)get_cv(SvPV_nolen(fq), 0));
                             break;
                         default:
                             continue;
@@ -149,7 +148,7 @@ get_all_package_symbols(self, ...)
 
                 while ((he = hv_iternext(stash))) {
                     SV *key = hv_iterkeysv(he);
-                    SV *sv = hv_iterval(stash, he);
+                    SV *sv = HeVAL(he);
                     SPAGAIN;
                     PUSHs(key);
                     PUSHs(sv);