[VPM] inline c and weird buggy-ness

Jer A jeremygwa at hotmail.com
Mon Nov 13 14:45:58 PST 2006


hi there perl gurus.

I am creating a module in inline c. I want to concat a very large string 
fast. I am getting weird crashes for each run. Also, it appears that my 
string is not being concatinated at all.

I am using VC6.0, perl 5.8 on win32 xp.

how can I get this to work.

your help is appreciated. Thanks.

-Jer A.

---------------------------------------------------------------------
#!Perl

package DSTRING;

my $code = <<'END_C';


	void concat( char *a, char *b, char *c)
	{
		while( *a )  {           /* while( *c++ = *a++ );  */
			*c = *a; ++a; ++c;
		}
		while( *b )  {
			*c = *b; ++b; ++c;
		}
		*c = '\0';
	}


	char* addString(char* DATA,char* dataToAdd) {
    		concat(DATA, strdup(dataToAdd),DATA);
    		return DATA;
	}


END_C

use Inline;

Inline->bind(C => $code);

1;

my $data = "";

my $count = 0;
for(1...100000)
{
	print $count,"\n";

	$data = DSTRING::addString($data,"testdata");
	$count++;
}


print $data;

print "END\n";

_________________________________________________________________
Ready for the world's first international mobile film festival celebrating 
the creative potential of today's youth? Check out Mobile Jam Fest for your 
a chance to WIN $10,000! www.mobilejamfest.com



More information about the Victoria-pm mailing list