Changeset - r11216:1fb6ec55b11b
[Not reviewed]
master
0 3 0
smatz - 15 years ago 2009-02-24 21:32:23
smatz@openttd.org
(svn r15569) -Codechange: replace MallocT + memset( 0 ) calls by CallocT
3 files changed with 6 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/oldpool.cpp
Show inline comments
 
@@ -55,10 +55,7 @@ bool OldMemoryPoolBase::AddBlockToPool()
 
	this->blocks = ReallocT(this->blocks, this->current_blocks + 1);
 

	
 
	/* Allocate memory to the new block item */
 
	this->blocks[this->current_blocks] = MallocT<byte>(this->item_size * (1 << this->block_size_bits));
 

	
 
	/* Clean the content of the new block */
 
	memset(this->blocks[this->current_blocks], 0, this->item_size * (1 << this->block_size_bits));
 
	this->blocks[this->current_blocks] = CallocT<byte>(this->item_size * (1 << this->block_size_bits));
 

	
 
	/* Call a custom function if defined (e.g. to fill indexes) */
 
	if (this->new_block_proc != NULL) this->new_block_proc(this->current_blocks * (1 << this->block_size_bits));
src/screenshot.cpp
Show inline comments
 
@@ -126,8 +126,7 @@ static bool MakeBmpImage(const char *nam
 
	maxlines = Clamp(65536 / padw, 16, 128);
 

	
 
	/* now generate the bitmap bits */
 
	void *buff = MallocT<uint8>(padw * maxlines * bpp); // by default generate 128 lines at a time.
 
	memset(buff, 0, padw * maxlines); // zero the buffer to have the padding bytes set to 0
 
	uint8 *buff = CallocT<uint8>(padw * maxlines * bpp); // by default generate 128 lines at a time.
 

	
 
	/* start at the bottom, since bitmaps are stored bottom up. */
 
	do {
 
@@ -140,7 +139,7 @@ static bool MakeBmpImage(const char *nam
 

	
 
		/* write each line */
 
		while (n)
 
			if (fwrite((uint8 *)buff + (--n) * padw * bpp, padw * bpp, 1, f) != 1) {
 
			if (fwrite(buff + (--n) * padw * bpp, padw * bpp, 1, f) != 1) {
 
				free(buff);
 
				fclose(f);
 
				return false;
 
@@ -250,8 +249,7 @@ static bool MakePNGImage(const char *nam
 
	maxlines = Clamp(65536 / w, 16, 128);
 

	
 
	/* now generate the bitmap bits */
 
	void *buff = MallocT<uint8>(w * maxlines * bpp); // by default generate 128 lines at a time.
 
	memset(buff, 0, w * maxlines * bpp);
 
	void *buff = CallocT<uint8>(w * maxlines * bpp); // by default generate 128 lines at a time.
 

	
 
	y = 0;
 
	do {
 
@@ -345,8 +343,7 @@ static bool MakePCXImage(const char *nam
 
	maxlines = Clamp(65536 / w, 16, 128);
 

	
 
	/* now generate the bitmap bits */
 
	uint8 *buff = MallocT<uint8>(w * maxlines); // by default generate 128 lines at a time.
 
	memset(buff, 0, w * maxlines); // zero the buffer to have the padding bytes set to 0
 
	uint8 *buff = CallocT<uint8>(w * maxlines); // by default generate 128 lines at a time.
 

	
 
	y = 0;
 
	do {
src/vehicle.cpp
Show inline comments
 
@@ -37,7 +37,6 @@
 
#include "ai/ai.hpp"
 
#include "core/smallmap_type.hpp"
 
#include "vehiclelist.h"
 
#include "core/mem_func.hpp"
 
#include "depot_func.h"
 
#include "settings_type.h"
 

	
 
@@ -1746,9 +1745,7 @@ FreeUnitIDGenerator::FreeUnitIDGenerator
 
	this->maxid++; // so there is space for last item (with v->unitnumber == maxid)
 
	this->maxid++; // this one will always be free (well, it will fail when there are 65535 units, so this overflows)
 

	
 
	this->cache = MallocT<bool>(this->maxid);
 

	
 
	MemSetT(this->cache, 0, this->maxid);
 
	this->cache = CallocT<bool>(this->maxid);
 

	
 
	/* Fill the cache */
 
	FOR_ALL_VEHICLES(v) {
0 comments (0 inline, 0 general)