mirror of https://github.com/OpenTTD/OpenTTD
Codechange: remove ZeroedMemoryAllocator
parent
adb0858c05
commit
15dcf56dad
|
@ -10,8 +10,6 @@
|
||||||
#ifndef ALLOC_TYPE_HPP
|
#ifndef ALLOC_TYPE_HPP
|
||||||
#define ALLOC_TYPE_HPP
|
#define ALLOC_TYPE_HPP
|
||||||
|
|
||||||
#include "alloc_func.hpp"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A reusable buffer that can be used for places that temporary allocate
|
* A reusable buffer that can be used for places that temporary allocate
|
||||||
* a bit of memory and do that very often, or for places where static
|
* a bit of memory and do that very often, or for places where static
|
||||||
|
@ -63,41 +61,4 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Base class that provides memory initialization on dynamically created objects.
|
|
||||||
* All allocated memory will be zeroed.
|
|
||||||
*/
|
|
||||||
class ZeroedMemoryAllocator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ZeroedMemoryAllocator() {}
|
|
||||||
virtual ~ZeroedMemoryAllocator() = default;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory allocator for a single class instance.
|
|
||||||
* @param size the amount of bytes to allocate.
|
|
||||||
* @return the given amounts of bytes zeroed.
|
|
||||||
*/
|
|
||||||
inline void *operator new(size_t size) { return CallocT<uint8_t>(size); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory allocator for an array of class instances.
|
|
||||||
* @param size the amount of bytes to allocate.
|
|
||||||
* @return the given amounts of bytes zeroed.
|
|
||||||
*/
|
|
||||||
inline void *operator new[](size_t size) { return CallocT<uint8_t>(size); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory release for a single class instance.
|
|
||||||
* @param ptr the memory to free.
|
|
||||||
*/
|
|
||||||
inline void operator delete(void *ptr) { free(ptr); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Memory release for an array of class instances.
|
|
||||||
* @param ptr the memory to free.
|
|
||||||
*/
|
|
||||||
inline void operator delete[](void *ptr) { free(ptr); }
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* ALLOC_TYPE_HPP */
|
#endif /* ALLOC_TYPE_HPP */
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
|
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "core/alloc_func.hpp"
|
||||||
#include "gfx_layout.h"
|
#include "gfx_layout.h"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "zoom_func.h"
|
#include "zoom_func.h"
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
/** @file gfx_layout.cpp Handling of laying out text. */
|
/** @file gfx_layout.cpp Handling of laying out text. */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "core/alloc_func.hpp"
|
||||||
#include "core/math_func.hpp"
|
#include "core/math_func.hpp"
|
||||||
#include "gfx_layout.h"
|
#include "gfx_layout.h"
|
||||||
#include "string_func.h"
|
#include "string_func.h"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <sqstdaux.h>
|
#include <sqstdaux.h>
|
||||||
#include <../squirrel/sqpcheader.h>
|
#include <../squirrel/sqpcheader.h>
|
||||||
#include <../squirrel/sqvm.h>
|
#include <../squirrel/sqvm.h>
|
||||||
|
#include "../core/alloc_func.hpp"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In the memory allocator for Squirrel we want to directly use malloc/realloc, so when the OS
|
* In the memory allocator for Squirrel we want to directly use malloc/realloc, so when the OS
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
/** @file spritecache.cpp Caching of sprites. */
|
/** @file spritecache.cpp Caching of sprites. */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "core/alloc_func.hpp"
|
||||||
#include "random_access_file_type.h"
|
#include "random_access_file_type.h"
|
||||||
#include "spriteloader/grf.hpp"
|
#include "spriteloader/grf.hpp"
|
||||||
#include "spriteloader/makeindexed.h"
|
#include "spriteloader/makeindexed.h"
|
||||||
|
|
Loading…
Reference in New Issue