10 struct pool_head swap_table;
13 struct block_pool swap_block_pool;
14 #endif /* INDIRECT_SWAP */
16 static void swap_move(struct pool_item *item, int new_base) {
17 #if 0 // only called for block under realloc, whose contents are ignored
22 blocks = item->limit - base;
23 //printf("swap_move [%d,%d) to [%d,%d)\n", base, base + blocks, new_base, new_base + blocks);
24 assert(new_base <= base || new_base >= base + blocks);
26 for (i = 0; i < blocks; ++i) {
27 swap_table_mem[new_base + i] = swap_table_mem[base + i];
28 swap_table_mem[base + i] = 0x55555555;
33 static void swap_move_up(struct pool_item *item, int new_base) {
34 #if 0 // only called for block under realloc, whose contents are ignored
39 blocks = limit - item->base;
40 printf("swap_move_up [%d,%d) to [%d,%d)\n", limit - blocks, limit, new_limit - blocks, new_limit);
41 assert(new_limit >= limit || new_limit <= limit - blocks);
44 for (i = -1; i >= blocks; --i) {
45 swap_table_mem[new_limit + i] = swap_table_mem[limit + i];
46 swap_table_mem[limit + i] = 0x55555555;
52 void swap_init(int n_blocks)
53 #else /* INDIRECT_SWAP */
54 void swap_init(int n_blocks, int table_size)
55 #endif /* INDIRECT_SWAP */
62 #else /* INDIRECT_SWAP */
64 #endif /* INDIRECT_SWAP */
70 swap_table_mem = malloc(table_size * sizeof(int));
71 rassert(swap_table_mem);
72 memset(swap_table_mem, 0x55, table_size * sizeof(int));
74 block_pool_init(&swap_block_pool, n_blocks);
75 #endif /* INDIRECT_SWAP */