47 pool->total_items = (pool->current_blocks + 1) * (1 << pool->block_size_bits); |
48 pool->total_items = (pool->current_blocks + 1) * (1 << pool->block_size_bits); |
48 |
49 |
49 DEBUG(misc, 4, "[Pool] (%s) increasing size of pool to %d items (%d bytes)", pool->name, pool->total_items, pool->total_items * pool->item_size); |
50 DEBUG(misc, 4, "[Pool] (%s) increasing size of pool to %d items (%d bytes)", pool->name, pool->total_items, pool->total_items * pool->item_size); |
50 |
51 |
51 /* Increase the poolsize */ |
52 /* Increase the poolsize */ |
52 pool->blocks = realloc(pool->blocks, sizeof(pool->blocks[0]) * (pool->current_blocks + 1)); |
53 ReallocT(&pool->blocks, pool->current_blocks + 1); |
53 if (pool->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", pool->name); |
54 if (pool->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", pool->name); |
54 |
55 |
55 /* Allocate memory to the new block item */ |
56 /* Allocate memory to the new block item */ |
56 pool->blocks[pool->current_blocks] = malloc(pool->item_size * (1 << pool->block_size_bits)); |
57 MallocT(&pool->blocks[pool->current_blocks], pool->item_size * (1 << pool->block_size_bits)); |
57 if (pool->blocks[pool->current_blocks] == NULL) |
58 if (pool->blocks[pool->current_blocks] == NULL) |
58 error("Pool: (%s) could not allocate memory for blocks", pool->name); |
59 error("Pool: (%s) could not allocate memory for blocks", pool->name); |
59 |
60 |
60 /* Clean the content of the new block */ |
61 /* Clean the content of the new block */ |
61 memset(pool->blocks[pool->current_blocks], 0, pool->item_size * (1 << pool->block_size_bits)); |
62 memset(pool->blocks[pool->current_blocks], 0, pool->item_size * (1 << pool->block_size_bits)); |