OpenTTD Source: src/safeguards.h File Reference

OpenTTD Source 15.0-beta1

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

## Macro Definition Documentation

## ◆ calloc

#define calloc SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 26 of file safeguards.h.

## ◆ fprintf

#define fprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 59 of file safeguards.h.

## ◆ fputs

#define fputs SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 61 of file safeguards.h.

## ◆ gets

#define gets SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 52 of file safeguards.h.

## ◆ malloc

#define malloc SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 23 of file safeguards.h.

## ◆ printf

#define printf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 58 of file safeguards.h.

## ◆ putchar

#define putchar SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 62 of file safeguards.h.

## ◆ puts

#define puts SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 60 of file safeguards.h.

## ◆ realloc

#define realloc SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 29 of file safeguards.h.

## ◆ snprintf

#define snprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 45 of file safeguards.h.

## ◆ sprintf

#define sprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 44 of file safeguards.h.

## ◆ strcat

#define strcat SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 40 of file safeguards.h.

## ◆ strcpy

#define strcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 36 of file safeguards.h.

## ◆ strdup

#define strdup SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 32 of file safeguards.h.

## ◆ strncat

#define strncat SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 41 of file safeguards.h.

## ◆ strncpy

#define strncpy SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 37 of file safeguards.h.

## ◆ strndup

#define strndup SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 33 of file safeguards.h.

## ◆ strtok

#define strtok SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 55 of file safeguards.h.

## ◆ vsnprintf

#define vsnprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 49 of file safeguards.h.

## ◆ vsprintf

#define vsprintf SAFEGUARD_DO_NOT_USE_THIS_METHOD

Definition at line 48 of file safeguards.h.