From 6fc28d649eed7a192b43669e7bd6458f118d7a6d Mon Sep 17 00:00:00 2001 From: Charles Pigott Date: Tue, 11 Apr 2023 08:40:50 +0100 Subject: [PATCH] Cleanup: Unused alloca definitions and includes --- src/animated_tile.cpp | 1 - src/core/alloc_func.hpp | 5 ----- src/core/smallvec_type.hpp | 1 - src/newgrf_storage.h | 1 + src/os/windows/crashlog_win.cpp | 1 - src/saveload/animated_tile_sl.cpp | 1 - src/saveload/strings_sl.cpp | 1 + src/script/api/script_cargo.cpp | 1 + src/script/squirrel_helper.hpp | 2 +- src/script/squirrel_std.cpp | 1 - src/stdafx.h | 10 ---------- src/strgen/strgen_base.cpp | 1 + src/stringfilter.cpp | 1 + 13 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 5329b2b506..e31d1b8e03 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -8,7 +8,6 @@ /** @file animated_tile.cpp Everything related to animated tiles. */ #include "stdafx.h" -#include "core/alloc_func.hpp" #include "core/smallvec_type.hpp" #include "tile_cmd.h" #include "viewport_func.h" diff --git a/src/core/alloc_func.hpp b/src/core/alloc_func.hpp index e8436e28d7..dc3ed483eb 100644 --- a/src/core/alloc_func.hpp +++ b/src/core/alloc_func.hpp @@ -128,9 +128,4 @@ static inline T *ReallocT(T *t_ptr, size_t num_elements) return t_ptr; } -/** alloca() has to be called in the parent function, so define AllocaM() as a macro */ -#define AllocaM(T, num_elements) \ - (CheckAllocationConstraints(num_elements), \ - (T*)alloca((num_elements) * sizeof(T))) - #endif /* ALLOC_FUNC_HPP */ diff --git a/src/core/smallvec_type.hpp b/src/core/smallvec_type.hpp index 92fd938be5..087f217971 100644 --- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -10,7 +10,6 @@ #ifndef SMALLVEC_TYPE_HPP #define SMALLVEC_TYPE_HPP -#include "alloc_func.hpp" #include "mem_func.hpp" #include diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index 819e8d9394..0c2f0e33a0 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -10,6 +10,7 @@ #ifndef NEWGRF_STORAGE_H #define NEWGRF_STORAGE_H +#include "core/alloc_func.hpp" #include "core/pool_type.hpp" #include "tile_type.h" diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index e5c5cd6b88..6479f60a99 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -10,7 +10,6 @@ #include "../../stdafx.h" #include "../../crashlog.h" #include "win32.h" -#include "../../core/alloc_func.hpp" #include "../../core/math_func.hpp" #include "../../string_func.h" #include "../../fileio_func.h" diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index 282968f9b4..a36366125a 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -13,7 +13,6 @@ #include "compat/animated_tile_sl_compat.h" #include "../tile_type.h" -#include "../core/alloc_func.hpp" #include "../core/smallvec_type.hpp" #include "../safeguards.h" diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp index 512a743d98..6e4d779687 100644 --- a/src/saveload/strings_sl.cpp +++ b/src/saveload/strings_sl.cpp @@ -8,6 +8,7 @@ /** @file strings_sl.cpp Code handling saving and loading of strings */ #include "../stdafx.h" +#include "../core/alloc_func.hpp" #include "../string_func.h" #include "../strings_func.h" #include "saveload_internal.h" diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp index aad2425461..b0377a3e0e 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -10,6 +10,7 @@ #include "../../stdafx.h" #include "script_cargo.hpp" #include "../../economy_func.h" +#include "../../core/alloc_func.hpp" #include "../../core/bitmath_func.hpp" #include "../../strings_func.h" #include "../../settings_type.h" diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index 47c5eb62a0..02b584fe49 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -11,7 +11,7 @@ #define SQUIRREL_HELPER_HPP #include "squirrel.hpp" -#include "../core/smallvec_type.hpp" +#include "../core/alloc_func.hpp" #include "../economy_type.h" #include "../string_func.h" #include "../tile_type.h" diff --git a/src/script/squirrel_std.cpp b/src/script/squirrel_std.cpp index 82943e5268..e04ebf4cc9 100644 --- a/src/script/squirrel_std.cpp +++ b/src/script/squirrel_std.cpp @@ -12,7 +12,6 @@ #include #include "../debug.h" #include "squirrel_std.hpp" -#include "../core/alloc_func.hpp" #include "../core/math_func.hpp" #include "../string_func.h" diff --git a/src/stdafx.h b/src/stdafx.h index d7da1ad8fc..b636e2d7bf 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -118,10 +118,6 @@ # define strcasecmp stricmp #endif -#if defined(SUNOS) || defined(HPUX) || defined(__CYGWIN__) -# include -#endif - /* Stuff for GCC */ #if defined(__GNUC__) || (defined(__clang__) && !defined(_MSC_VER)) # define NORETURN __attribute__ ((noreturn)) @@ -172,10 +168,6 @@ # include #endif /* __WATCOMC__ */ -#if defined(__MINGW32__) -# include // alloca() -#endif - #if defined(_WIN32) # define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #endif @@ -199,7 +191,6 @@ # pragma warning(disable: 6011) // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001 # pragma warning(disable: 6326) // code analyzer: potential comparison of a constant with another constant # pragma warning(disable: 6031) // code analyzer: Return value ignored: 'ReadFile' -# pragma warning(disable: 6255) // code analyzer: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead # pragma warning(disable: 6246) // code analyzer: Local declaration of 'statspec' hides declaration of the same name in outer scope. For additional information, see previous declaration at ... # if (_MSC_VER == 1500) // Addresses item #13 on http://blogs.msdn.com/b/vcblog/archive/2008/08/11/tr1-fixes-in-vc9-sp1.aspx, for Visual Studio 2008 @@ -207,7 +198,6 @@ # include # endif -# include // alloca() # define NORETURN __declspec(noreturn) # if (_MSC_VER < 1900) # define inline __forceinline diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 7d37c3b4e6..84122fe4ba 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -8,6 +8,7 @@ /** @file strgen_base.cpp Tool to create computer readable (stand-alone) translation files. */ #include "../stdafx.h" +#include "../core/alloc_func.hpp" #include "../core/endian_func.hpp" #include "../string_func.h" #include "../table/control_codes.h" diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index 4765a880e1..28a12eab2c 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -8,6 +8,7 @@ /** @file stringfilter.cpp Searching and filtering using a stringterm. */ #include "stdafx.h" +#include "core/alloc_func.hpp" #include "string_func.h" #include "strings_func.h" #include "stringfilter_type.h"