Maintain a circular buffer of recent commands, add to crashlog.
[openttd-joker.git] / src / safeguards.h
blobf447627e681cc86c5b5dcfdb1783d54e5afea697
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /**
11 * @file safeguards.h A number of safeguards to prevent using unsafe methods.
13 * Unsafe methods are, for example, strndup and strncpy because they may leave the
14 * string without a null termination, but also strdup and strndup because they can
15 * return NULL and then all strdups would need to be guarded against that instead
16 * of using the current MallocT/ReallocT/CallocT technique of just giving the user
17 * an error that too much memory was used instead of spreading that code though
18 * the whole code base.
21 #ifndef SAFEGUARDS_H
22 #define SAFEGUARDS_H
24 /* Use MallocT instead. */
25 #define malloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
27 /* Use MallocT instead. */
28 #define calloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
30 /* Use ReallocT instead. */
31 #define realloc SAFEGUARD_DO_NOT_USE_THIS_METHOD
33 /* Use stredup instead. */
34 #define strdup SAFEGUARD_DO_NOT_USE_THIS_METHOD
35 #define strndup SAFEGUARD_DO_NOT_USE_THIS_METHOD
37 /* Use strecpy instead. */
38 #define strcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD
39 #define strncpy SAFEGUARD_DO_NOT_USE_THIS_METHOD
41 /* Use strecat instead. */
42 #define strcat SAFEGUARD_DO_NOT_USE_THIS_METHOD
43 #define strncat SAFEGUARD_DO_NOT_USE_THIS_METHOD
45 /* Use seprintf instead. */
46 #define sprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
47 #define snprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
49 /* Use vseprintf instead. */
50 #define vsprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
51 #define vsnprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD
53 /* Use fgets instead. */
54 #define gets SAFEGUARD_DO_NOT_USE_THIS_METHOD
56 /* No clear replacement. */
57 #define strtok SAFEGUARD_DO_NOT_USE_THIS_METHOD
59 /* Use our own templated implementation instead of a macro or function with only one type. */
60 #ifdef min
61 #undef min
62 #endif
64 /* Use our own templated implementation instead of a macro or function with only one type. */
65 #ifdef max
66 #undef max
67 #endif
69 /* Use our own templated implementation instead of a macro or function with only one type. */
70 #ifdef abs
71 #undef abs
72 #endif
74 #endif /* SAFEGUARDS_H */