OpenTTD Source  20240915-master-g3784a3d3d6
safeguards.h File Reference

Go to the source code of this file.

Macros

#define malloc   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define calloc   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define realloc   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strdup   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strndup   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strcpy   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strncpy   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strcat   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strncat   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define sprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define snprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define vsprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define vsnprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define gets   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strtok   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define printf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define fprintf   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define puts   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define fputs   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define putchar   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

Detailed Description

A number of safeguards to prevent using unsafe methods.

Unsafe methods are, for example, strndup and strncpy because they may leave the string without a null termination, but also strdup and strndup because they can return nullptr and then all strdups would need to be guarded against that instead of using the current MallocT/ReallocT/CallocT technique of just giving the user an error that too much memory was used instead of spreading that code though the whole code base.

Definition in file safeguards.h.