Next: , Previous: , Up: Garbage Collection - Step by Step   [Contents][Index]


11.4.6 compact_string_chars

The purpose of this function is to compact all the data parts of the strings that are held in so-called string_chars_block, i.e. the strings that do not exceed a certain maximal length.

The procedure with which this is done is as follows. We are keeping two positions in the string_chars_blocks using two pointer/integer pairs, namely from_sb/from_pos and to_sb/to_pos. They stand for the actual positions, from where to where, to copy the actually handled string.

While going over all chained string_char_blocks and their held strings, staring at first_string_chars_block, both pointers are advanced and eventually a string is copied from from_sb to to_sb, depending on the status of the pointed at strings.

More precisely, we can distinguish between the following actions.

After compacting, the pointer to the current string_chars_block, sitting in current_string_chars_block, is reset on the last block to which we moved a string, i.e. to_block, and all remaining blocks (we know that they just carry garbage) are explicitly xfreed.


Next: , Previous: , Up: Garbage Collection - Step by Step   [Contents][Index]