From: Dave Rolsky Date: Mon, 25 Aug 2008 04:54:21 +0000 (+0000) Subject: Replace the alloca and snprintf stuff with equivalent XS API code, X-Git-Tag: 0.64_05~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd27f6e9a3b9c9db36a7e0d9f1c0e24b67b34417;p=gitmo%2FClass-MOP.git Replace the alloca and snprintf stuff with equivalent XS API code, which should work on all platforms. Visual C++ was barfing on these functions, apparently. --- diff --git a/MOP.xs b/MOP.xs index e4bdb81..2b50ab6 100644 --- a/MOP.xs +++ b/MOP.xs @@ -100,16 +100,12 @@ 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; + SV *fq; switch( SvTYPE(gv) ) { case SVt_PVGV: @@ -125,12 +121,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); + char *package = HvNAME(stash); + fq = newSVpvf("%s::%s", package, key); + sv = sv_2mortal((SV*)get_cv(SvPV_nolen(fq), 0)); break; default: continue;