OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Macros
safeguards.h File Reference

A number of safeguards to prevent using unsafe methods. More...

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

## 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 NULL 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.