summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-08-02 21:02:57 +0000
committerrubidium <rubidium@openttd.org>2007-08-02 21:02:57 +0000
commit2c9e166e7e012be1dcdcae96c1043bdec669c130 (patch)
tree6ea8fed8f6fd7d70bf4dabdd554fe9d7e647b7fe
parentf9c6775dfd44e962f047be7671198bce2e08a356 (diff)
downloadopenttd-2c9e166e7e012be1dcdcae96c1043bdec669c130.tar.xz
(svn r10754) -Fix: MorphOS does not like sizeof in the templated pool item class, so use the item size that is set in the pool.
-rw-r--r--src/oldpool.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/oldpool.h b/src/oldpool.h
index 6157ddded..4c1b757bf 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -23,15 +23,14 @@ struct OldMemoryPoolBase {
protected:
OldMemoryPoolBase(const char *name, uint max_blocks, uint block_size_bits, uint item_size,
OldMemoryPoolNewBlock *new_block_proc, OldMemoryPoolCleanBlock *clean_block_proc) :
- name(name), max_blocks(max_blocks), block_size_bits(block_size_bits), item_size(item_size),
+ name(name), max_blocks(max_blocks), block_size_bits(block_size_bits),
new_block_proc(new_block_proc), clean_block_proc(clean_block_proc), current_blocks(0),
- total_items(0), blocks(NULL) {}
+ total_items(0), item_size(item_size), first_free_index(0), blocks(NULL) {}
const char* name; ///< Name of the pool (just for debugging)
const uint max_blocks; ///< The max amount of blocks this pool can have
const uint block_size_bits; ///< The size of each block in bits
- const uint item_size; ///< How many bytes one block is
/// Pointer to a function that is called after a new block is added
OldMemoryPoolNewBlock *new_block_proc;
@@ -42,6 +41,7 @@ protected:
uint total_items; ///< How many items we now have in this pool
public:
+ const uint item_size; ///< How many bytes one block is
uint first_free_index; ///< The index of the first free pool item in this pool
byte **blocks; ///< An array of blocks (one block hold all the items)
@@ -102,7 +102,7 @@ struct OldMemoryPool : public OldMemoryPoolBase {
{
assert(index < this->GetSize());
return (T*)(this->blocks[index >> this->block_size_bits] +
- (index & ((1 << this->block_size_bits) - 1)) * sizeof(T));
+ (index & ((1 << this->block_size_bits) - 1)) * this->item_size);
}
};
@@ -266,7 +266,7 @@ private:
Tpool->first_free_index = t->index;
Tid index = t->index;
- memset(t, 0, sizeof(T));
+ memset(t, 0, Tpool->item_size);
t->index = index;
return t;
}