in reply to .XS segfault
I'm no XS expert (I prefer Inline::C) but SIGSEGV leads me to believe you're blowing the stack. PUSHs will not automatically expand the stack for you. Try XPUSHs instead. Just out of curiosity, does the dir you're SIGSEGV'ing on have many more entries than the dirs it works okay on?
-derby
update: I couldn't resist a little Inline::C rewrite:
#!/usr/local/bin/perl -w use Inline C; use strict; foreach( @ARGV ) { my( @stuff ) = readdir_inode($_); foreach(@stuff) { foreach( @$_ ) { print $_, " "; } print "\n"; } } __END__ __C__ #include <sys/types.h> #include <dirent.h> #include <stdio.h> void readdir_inode ( char *dirname ) { struct dirent *ent; DIR *dir; SV *record[2]; AV *entry, *ret_val; Inline_Stack_Vars; Inline_Stack_Reset; dir = opendir(dirname); if( dir ) { while( ent=readdir(dir) ) { record[0] = newSVpv(ent->d_name, 0 ); record[1] = newSViv((IV)ent->d_ino); Inline_Stack_Push(newRV_noinc((SV*)av_make(2,r +ecord))); } closedir(dir); } Inline_Stack_Done; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: .XS segfault
by mugwumpjism (Hermit) on Mar 08, 2002 at 16:09 UTC | |
by derby (Abbot) on Mar 08, 2002 at 16:46 UTC |