meetraz has asked for the wisdom of the Perl Monks concerning the following question:
my $hashref; my $result = dir_size("C:\\temp", $hashref); print "File count = ", $hashref->{FileCount}, "\n"; print "Dir size = ", $hashref->{LowSize}, "\n";
I have this XS function defined:
int dir_size (dirname,dirinfo,permsdie=0,otherdie=0) PREINIT: AV *errs = newAV(); HV *newdirinfo = newHV(); unsigned long hightotalsize = 0; unsigned long lowtotalsize = 0; long filecount = 0; long dircount = 0; INPUT: SV *dirinfo; char *dirname; int permsdie; int otherdie; CODE: RETVAL = _dir_size (errs, permsdie, otherdie, dirname, &highto +talsize, &lowtotalsize, &filecount, &dircount); hv_store(newdirinfo, "Errors", 6, newRV((SV *)errs), 0) +; hv_store(newdirinfo, "HighSize", 8, newSVuv(hightotalsize), + 0); hv_store(newdirinfo, "LowSize", 7, newSVuv(lowtotalsize +), 0); hv_store(newdirinfo, "FileCount", 9, newSViv(filecount), 0) +; hv_store(newdirinfo, "DirCount", 8, newSViv(dircount), 0); dirinfo = newRV_noinc((SV *)newdirinfo); printf("Found %i files\n", filecount); OUTPUT: dirinfo RETVAL
The printf() call in the above XS spits out the right number, but back in perl, my $hashref is undef. Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XS returning undef?
by jand (Friar) on Mar 09, 2003 at 08:07 UTC | |
by meetraz (Hermit) on Mar 09, 2003 at 08:13 UTC | |
by jand (Friar) on Mar 09, 2003 at 08:21 UTC | |
by PodMaster (Abbot) on Mar 09, 2003 at 08:22 UTC | |
|
Re: XS returning undef?
by PodMaster (Abbot) on Mar 09, 2003 at 07:36 UTC | |
by meetraz (Hermit) on Mar 09, 2003 at 07:44 UTC |