Skip to content

Instantly share code, notes, and snippets.

@masak
Created July 9, 2010 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/469980 to your computer and use it in GitHub Desktop.
Save masak/469980 to your computer and use it in GitHub Desktop.
multi method write(Buf $buf) {
my @contents = $buf.contents;
my $pio = $!PIO;
Q:PIR {
$P0 = find_lex '@contents'
.local pmc bb
.local string s
bb = new ['ByteBuffer']
.local pmc it
.local int i
it = iter $P0
i = 0
loop:
unless it goto done
$P1 = shift it
$I1 = $P1
bb[i] = $I1
inc i
goto loop
done:
s = bb.'get_string_as'(binary:"")
.local pmc pio
pio = find_lex '$pio'
pio.'print'(s) # Segmentation fault on this call
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment