21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 12-1. Memory representation of split arrays<br />

Before merge<br />

Before split<br />

Figure 12-2. Memory representation of merged arrays<br />

Folded arrays created using the spc_array_fold( ) function become multidimensional<br />

arrays, similar to the two-dimensional arrays created with spc_array_split( ).<br />

Each array element is referenced by an index as if it were in a single-dimensional<br />

array. The number of dimensions chosen determines the ordering of the elements.<br />

The memory representation of folded arrays is illustrated in Figure 12-3.<br />

Figure 12-3. Memory representation of folded arrays<br />

The spc_array_flat( ) function stores multiple arrays or a multidimensional array as<br />

a single-dimensional array with each element referenced by an array number and an<br />

index into that array. The first element of each array is stored, followed by the second<br />

element of each array, and so forth until the end of the arrays are reached. Note<br />

that not all arrays need be the same size for this to work correctly, as long as the<br />

space reserved for the one-dimensional array contains NULL entries for the unused elements.<br />

The memory representation of flat arrays is illustrated in Figure 12-4.<br />

Figure 12-4. Memory representation of flat arrays<br />

676 | Chapter 12: Anti-Tampering<br />

A1 A2 A3 A4 A5 A6<br />

A1 A2 A3 A4 A5 A6 A7<br />

B1 B2 B3<br />

Before fold<br />

A1 A2 A3 A4 A5 A6 A7<br />

Before flatten<br />

A11 A12 A13 A 21 A 22 A 23<br />

A 31 A 32 A 33<br />

After merge<br />

After split<br />

A1 A3 A5<br />

A2 A4 A6<br />

A1 A2 B1 A3 A4 B2 A5 A6 B3 A7<br />

After fold<br />

A8 A1 A4 A7<br />

A2 A5 A8<br />

A3 A6<br />

After flatten<br />

A11 A21 A31 A12 A22 A32 A13 A23 This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

A 33

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!