summaryrefslogtreecommitdiffstats
path: root/mkindex.pl
diff options
context:
space:
mode:
Diffstat (limited to 'mkindex.pl')
-rwxr-xr-xmkindex.pl16
1 files changed, 9 insertions, 7 deletions
diff --git a/mkindex.pl b/mkindex.pl
index 97fdf93..ed75907 100755
--- a/mkindex.pl
+++ b/mkindex.pl
@@ -498,7 +498,6 @@ sub expand_rgba {
my $src_data = $src_band->ReadRaster(0, $y, $xSize, 1);
for (my $b = 0; $b < $dst_nb; $b++) {
- local $_ = $src_data;
# We use an inlined C function to speed up things a bit.
# Essentially what we're doing is a splice through the
# lookup table.
@@ -507,8 +506,8 @@ sub expand_rgba {
# than our C code, can be obtained using transliteration:
# my $src_str = join '', map chr, (0 .. $src_nc-1);
# eval "tr/\Q$src_str\E/\Q$lookup->[$b]\E/";
- &subst ( $_, $lookup->[$b], $xSize );
- $dst_ds->Band(1+$b)->WriteRaster(0, $y, $xSize, 1, $_);
+ my $dst_data = &subst( $src_data, $lookup->[$b], $xSize );
+ $dst_ds->Band(1+$b)->WriteRaster(0, $y, $xSize, 1, $dst_data);
}
&{$config{progress}}( (1+$y) / $ySize ) if $config{progress};
@@ -687,8 +686,11 @@ __END__
__C__
-void subst (unsigned char *data, unsigned char *lookup, int length) {
- int i;
- for (i = 0; i < length; i++)
- data[i] = lookup[ data[i] ];
+SV *subst(unsigned char *data, unsigned char *lookup, int length) {
+ char *out = malloc(length * sizeof(unsigned char));
+ for (int i = 0; i < length; i++)
+ out[i] = lookup[ data[i] ];
+ SV* ret = newSVpvn(out, length);
+ free(out);
+ return(ret);
}