src/oldpool.cpp
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6800 6c09e1e86fcb
child 10455 22c441f5adf9
equal deleted inserted replaced
6871:5a9dc001e1ad 6872:1c4a4a609f85
     3 /** @file oldpool.cpp */
     3 /** @file oldpool.cpp */
     4 
     4 
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "debug.h"
     7 #include "debug.h"
     8 #include "functions.h"
       
     9 #include "oldpool.h"
     8 #include "oldpool.h"
    10 #include "helpers.hpp"
     9 #include "core/alloc_func.hpp"
    11 
    10 
    12 /**
    11 /**
    13  * Clean a pool in a safe way (does free all blocks)
    12  * Clean a pool in a safe way (does free all blocks)
    14  */
    13  */
    15 void OldMemoryPoolBase::CleanPool()
    14 void OldMemoryPoolBase::CleanPool()
    53 
    52 
    54 	DEBUG(misc, 4, "[Pool] (%s) increasing size of pool to %d items (%d bytes)", this->name, this->total_items, this->total_items * this->item_size);
    53 	DEBUG(misc, 4, "[Pool] (%s) increasing size of pool to %d items (%d bytes)", this->name, this->total_items, this->total_items * this->item_size);
    55 
    54 
    56 	/* Increase the poolsize */
    55 	/* Increase the poolsize */
    57 	this->blocks = ReallocT(this->blocks, this->current_blocks + 1);
    56 	this->blocks = ReallocT(this->blocks, this->current_blocks + 1);
    58 	if (this->blocks == NULL) error("Pool: (%s) could not allocate memory for blocks", this->name);
       
    59 
    57 
    60 	/* Allocate memory to the new block item */
    58 	/* Allocate memory to the new block item */
    61 	this->blocks[this->current_blocks] = MallocT<byte>(this->item_size * (1 << this->block_size_bits));
    59 	this->blocks[this->current_blocks] = MallocT<byte>(this->item_size * (1 << this->block_size_bits));
    62 	if (this->blocks[this->current_blocks] == NULL)
       
    63 		error("Pool: (%s) could not allocate memory for blocks", this->name);
       
    64 
    60 
    65 	/* Clean the content of the new block */
    61 	/* Clean the content of the new block */
    66 	memset(this->blocks[this->current_blocks], 0, this->item_size * (1 << this->block_size_bits));
    62 	memset(this->blocks[this->current_blocks], 0, this->item_size * (1 << this->block_size_bits));
    67 
    63 
    68 	/* Call a custom function if defined (e.g. to fill indexes) */
    64 	/* Call a custom function if defined (e.g. to fill indexes) */