1
0
Fork 0

Codechange: remove ZeroedMemoryAllocator

pull/13632/head
Rubidium 2025-02-22 21:01:43 +01:00 committed by rubidium42
parent adb0858c05
commit 15dcf56dad
5 changed files with 4 additions and 39 deletions

View File

@ -10,8 +10,6 @@
#ifndef ALLOC_TYPE_HPP
#define ALLOC_TYPE_HPP
#include "alloc_func.hpp"
/**
* 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
@ -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 */

View File

@ -8,6 +8,7 @@
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
#include "stdafx.h"
#include "core/alloc_func.hpp"
#include "gfx_layout.h"
#include "progress.h"
#include "zoom_func.h"

View File

@ -8,6 +8,7 @@
/** @file gfx_layout.cpp Handling of laying out text. */
#include "stdafx.h"
#include "core/alloc_func.hpp"
#include "core/math_func.hpp"
#include "gfx_layout.h"
#include "string_func.h"

View File

@ -17,6 +17,7 @@
#include <sqstdaux.h>
#include <../squirrel/sqpcheader.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

View File

@ -8,6 +8,7 @@
/** @file spritecache.cpp Caching of sprites. */
#include "stdafx.h"
#include "core/alloc_func.hpp"
#include "random_access_file_type.h"
#include "spriteloader/grf.hpp"
#include "spriteloader/makeindexed.h"