in reply to Re^5: Passing a bytestring from Perl to Inline::C as a 2d array
in thread Passing a bytestring from Perl to Inline::C as a 2d array
why even bother with pack()? Pass around something(... a hunk of memory) that is X x Y ints big
That is exactly what he is doing! He's also choosen to initialise it to zeros.
He could also have done that without using pack, say my $buf = chr(0) x ( $x_dimension * $y_dimension * 4 ), but that would then fail if the code is ever ported to a system where the C compiler ints are 64-bit. The way he has choesen to perform the initialisation makes it quite clear what memory represents. A good choice I think.
I am also challenging the need for 'C' in the first place.
You must have a crystal ball then, because I do not see enough information in the OP to give me the confidence to raise such a challenge.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Passing a bytestring from Perl to Inline::C as a 2d array
by Marshall (Canon) on Nov 14, 2009 at 19:14 UTC | |
by BrowserUk (Patriarch) on Nov 14, 2009 at 21:39 UTC |