SDL  2.0
SDL_stdinc.h File Reference
#include "SDL_config.h"
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <strings.h>
#include <wchar.h>
#include <inttypes.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include "begin_code.h"
#include <alloca.h>
#include "close_code.h"
+ Include dependency graph for SDL_stdinc.h:

Go to the source code of this file.

Macros

#define SDL_arraysize(array)   (sizeof(array)/sizeof(array[0]))
 
#define SDL_TABLESIZE(table)   SDL_arraysize(table)
 
#define SDL_STRINGIFY_ARG(arg)   #arg
 
#define SDL_FOURCC(A, B, C, D)
 
#define SDL_PRIs64   "I64d"
 
#define SDL_PRIu64   "I64u"
 
#define SDL_PRIx64   "I64x"
 
#define SDL_PRIX64   "I64X"
 
#define SDL_IN_BYTECAP(x)
 
#define SDL_INOUT_Z_CAP(x)
 
#define SDL_OUT_Z_CAP(x)
 
#define SDL_OUT_CAP(x)
 
#define SDL_OUT_BYTECAP(x)
 
#define SDL_OUT_Z_BYTECAP(x)
 
#define SDL_PRINTF_FORMAT_STRING
 
#define SDL_SCANF_FORMAT_STRING
 
#define SDL_PRINTF_VARARG_FUNC(fmtargnumber)
 
#define SDL_SCANF_VARARG_FUNC(fmtargnumber)
 
#define SDL_COMPILE_TIME_ASSERT(name, x)   typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]
 
#define SDL_stack_alloc(type, count)   (type*)alloca(sizeof(type)*(count))
 
#define SDL_stack_free(data)
 
#define SDL_min(x, y)   (((x) < (y)) ? (x) : (y))
 
#define SDL_max(x, y)   (((x) > (y)) ? (x) : (y))
 
#define SDL_zero(x)   SDL_memset(&(x), 0, sizeof((x)))
 
#define SDL_zerop(x)   SDL_memset((x), 0, sizeof(*(x)))
 
#define SDL_ICONV_ERROR   (size_t)-1
 
#define SDL_ICONV_E2BIG   (size_t)-2
 
#define SDL_ICONV_EILSEQ   (size_t)-3
 
#define SDL_ICONV_EINVAL   (size_t)-4
 
#define SDL_iconv_utf8_locale(S)   SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs2(S)   (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
#define SDL_iconv_utf8_ucs4(S)   (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)
 
Cast operators

Use proper C++ casts when compiled as C++ to be compatible with the option -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above).

#define SDL_reinterpret_cast(type, expression)   ((type)(expression))
 
#define SDL_static_cast(type, expression)   ((type)(expression))
 
#define SDL_const_cast(type, expression)   ((type)(expression))
 

Typedefs

typedef void *(* SDL_malloc_func) (size_t size)
 
typedef void *(* SDL_calloc_func) (size_t nmemb, size_t size)
 
typedef void *(* SDL_realloc_func) (void *mem, size_t size)
 
typedef void(* SDL_free_func) (void *mem)
 

Functions

voidSDL_malloc (size_t size)
 
voidSDL_calloc (size_t nmemb, size_t size)
 
voidSDL_realloc (void *mem, size_t size)
 
void SDL_free (void *mem)
 
void SDL_GetMemoryFunctions (SDL_malloc_func *malloc_func, SDL_calloc_func *calloc_func, SDL_realloc_func *realloc_func, SDL_free_func *free_func)
 Get the current set of SDL memory functions. More...
 
int SDL_SetMemoryFunctions (SDL_malloc_func malloc_func, SDL_calloc_func calloc_func, SDL_realloc_func realloc_func, SDL_free_func free_func)
 Replace SDL's memory allocation functions with a custom set. More...
 
int SDL_GetNumAllocations (void)
 Get the number of outstanding (unfreed) allocations. More...
 
char * SDL_getenv (const char *name)
 
int SDL_setenv (const char *name, const char *value, int overwrite)
 
void SDL_qsort (void *base, size_t nmemb, size_t size, int(*compare)(const void *, const void *))
 
int SDL_abs (int x)
 
int SDL_isdigit (int x)
 
int SDL_isspace (int x)
 
int SDL_toupper (int x)
 
int SDL_tolower (int x)
 
voidSDL_memset (SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
 
SDL_FORCE_INLINE void SDL_memset4 (void *dst, Uint32 val, size_t dwords)
 
voidSDL_memcpy (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
voidSDL_memmove (SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
 
int SDL_memcmp (const void *s1, const void *s2, size_t len)
 
size_t SDL_wcslen (const wchar_t *wstr)
 
size_t SDL_wcslcpy (SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
size_t SDL_wcslcat (SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
 
int SDL_wcscmp (const wchar_t *str1, const wchar_t *str2)
 
size_t SDL_strlen (const char *str)
 
size_t SDL_strlcpy (SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
size_t SDL_utf8strlcpy (SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_bytes)
 
size_t SDL_strlcat (SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
 
char * SDL_strdup (const char *str)
 
char * SDL_strrev (char *str)
 
char * SDL_strupr (char *str)
 
char * SDL_strlwr (char *str)
 
char * SDL_strchr (const char *str, int c)
 
char * SDL_strrchr (const char *str, int c)
 
char * SDL_strstr (const char *haystack, const char *needle)
 
size_t SDL_utf8strlen (const char *str)
 
char * SDL_itoa (int value, char *str, int radix)
 
char * SDL_uitoa (unsigned int value, char *str, int radix)
 
char * SDL_ltoa (long value, char *str, int radix)
 
char * SDL_ultoa (unsigned long value, char *str, int radix)
 
char * SDL_lltoa (Sint64 value, char *str, int radix)
 
char * SDL_ulltoa (Uint64 value, char *str, int radix)
 
int SDL_atoi (const char *str)
 
double SDL_atof (const char *str)
 
long SDL_strtol (const char *str, char **endp, int base)
 
unsigned long SDL_strtoul (const char *str, char **endp, int base)
 
Sint64 SDL_strtoll (const char *str, char **endp, int base)
 
Uint64 SDL_strtoull (const char *str, char **endp, int base)
 
double SDL_strtod (const char *str, char **endp)
 
int SDL_strcmp (const char *str1, const char *str2)
 
int SDL_strncmp (const char *str1, const char *str2, size_t maxlen)
 
int SDL_strcasecmp (const char *str1, const char *str2)
 
int SDL_strncasecmp (const char *str1, const char *str2, size_t len)
 
int SDL_sscanf (const char *text, SDL_SCANF_FORMAT_STRING const char *fmt,...) SDL_SCANF_VARARG_FUNC(2)
 
int SDL_vsscanf (const char *text, const char *fmt, va_list ap)
 
int SDL_snprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...) SDL_PRINTF_VARARG_FUNC(3)
 
int SDL_vsnprintf (SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
 
double SDL_acos (double x)
 
float SDL_acosf (float x)
 
double SDL_asin (double x)
 
float SDL_asinf (float x)
 
double SDL_atan (double x)
 
float SDL_atanf (float x)
 
double SDL_atan2 (double x, double y)
 
float SDL_atan2f (float x, float y)
 
double SDL_ceil (double x)
 
float SDL_ceilf (float x)
 
double SDL_copysign (double x, double y)
 
float SDL_copysignf (float x, float y)
 
double SDL_cos (double x)
 
float SDL_cosf (float x)
 
double SDL_fabs (double x)
 
float SDL_fabsf (float x)
 
double SDL_floor (double x)
 
float SDL_floorf (float x)
 
double SDL_fmod (double x, double y)
 
float SDL_fmodf (float x, float y)
 
double SDL_log (double x)
 
float SDL_logf (float x)
 
double SDL_log10 (double x)
 
float SDL_log10f (float x)
 
double SDL_pow (double x, double y)
 
float SDL_powf (float x, float y)
 
double SDL_scalbn (double x, int n)
 
float SDL_scalbnf (float x, int n)
 
double SDL_sin (double x)
 
float SDL_sinf (float x)
 
double SDL_sqrt (double x)
 
float SDL_sqrtf (float x)
 
double SDL_tan (double x)
 
float SDL_tanf (float x)
 
SDL_iconv_t SDL_iconv_open (const char *tocode, const char *fromcode)
 
int SDL_iconv_close (SDL_iconv_t cd)
 
size_t SDL_iconv (SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 
char * SDL_iconv_string (const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
 
SDL_FORCE_INLINE voidSDL_memcpy4 (SDL_OUT_BYTECAP(dwords *4) void *dst, SDL_IN_BYTECAP(dwords *4) const void *src, size_t dwords)
 

Basic data types

#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */
 A signed 8-bit integer type. More...
 
#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */
 
#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */
 An unsigned 8-bit integer type. More...
 
#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */
 
#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */
 A signed 16-bit integer type. More...
 
#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */
 
#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */
 An unsigned 16-bit integer type. More...
 
#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */
 
#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */
 A signed 32-bit integer type. More...
 
#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
 
#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */
 An unsigned 32-bit integer type. More...
 
#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */
 
#define SDL_MAX_SINT64   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
 A signed 64-bit integer type. More...
 
#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
 
#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
 An unsigned 64-bit integer type. More...
 
#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 0 */
 
enum  SDL_bool {
  SDL_FALSE = 0,
  SDL_TRUE = 1
}
 
typedef int8_t Sint8
 
typedef uint8_t Uint8
 
typedef int16_t Sint16
 
typedef uint16_t Uint16
 
typedef int32_t Sint32
 
typedef uint32_t Uint32
 
typedef int64_t Sint64
 
typedef uint64_t Uint64
 

Detailed Description

This is a general header that includes C language support.

Definition in file SDL_stdinc.h.

Macro Definition Documentation

◆ SDL_arraysize

◆ SDL_COMPILE_TIME_ASSERT

#define SDL_COMPILE_TIME_ASSERT (   name,
  x 
)    typedef int SDL_compile_time_assert_ ## name[(x) * 2 - 1]

Definition at line 290 of file SDL_stdinc.h.

Referenced by SDL_AtomicTryLock(), and TestTypes().

◆ SDL_const_cast

#define SDL_const_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 117 of file SDL_stdinc.h.

Referenced by SDL_strchr(), SDL_strrchr(), SDL_strstr(), and SDL_TLSSet().

◆ SDL_FOURCC

#define SDL_FOURCC (   A,
  B,
  C,
 
)
Value:
uint32_t Uint32
Definition: SDL_stdinc.h:181
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:116

Definition at line 122 of file SDL_stdinc.h.

◆ SDL_ICONV_E2BIG

#define SDL_ICONV_E2BIG   (size_t)-2

Definition at line 540 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_EILSEQ

#define SDL_ICONV_EILSEQ   (size_t)-3

Definition at line 541 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_ICONV_EINVAL

#define SDL_ICONV_EINVAL   (size_t)-4

Definition at line 542 of file SDL_stdinc.h.

Referenced by SDL_iconv(), and SDL_iconv_string().

◆ SDL_ICONV_ERROR

#define SDL_ICONV_ERROR   (size_t)-1

Definition at line 539 of file SDL_stdinc.h.

Referenced by SDL_iconv_string().

◆ SDL_iconv_utf8_locale

#define SDL_iconv_utf8_locale (   S)    SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 560 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs2

#define SDL_iconv_utf8_ucs2 (   S)    (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 561 of file SDL_stdinc.h.

◆ SDL_iconv_utf8_ucs4

#define SDL_iconv_utf8_ucs4 (   S)    (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1)

Definition at line 562 of file SDL_stdinc.h.

◆ SDL_IN_BYTECAP

#define SDL_IN_BYTECAP (   x)

Definition at line 272 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_INOUT_Z_CAP

#define SDL_INOUT_Z_CAP (   x)

Definition at line 273 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_max

◆ SDL_MAX_SINT16

#define SDL_MAX_SINT16   ((Sint16)0x7FFF) /* 32767 */

A signed 16-bit integer type.

Definition at line 161 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_SINT32

#define SDL_MAX_SINT32   ((Sint32)0x7FFFFFFF) /* 2147483647 */

A signed 32-bit integer type.

Definition at line 173 of file SDL_stdinc.h.

Referenced by SDL_CreateRGBSurfaceWithFormat(), and TestTypes().

◆ SDL_MAX_SINT64

#define SDL_MAX_SINT64   ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */

A signed 64-bit integer type.

Definition at line 186 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_SINT8

#define SDL_MAX_SINT8   ((Sint8)0x7F) /* 127 */

A signed 8-bit integer type.

Definition at line 149 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT16

#define SDL_MAX_UINT16   ((Uint16)0xFFFF) /* 65535 */

An unsigned 16-bit integer type.

Definition at line 167 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT32

#define SDL_MAX_UINT32   ((Uint32)0xFFFFFFFFu) /* 4294967295 */

An unsigned 32-bit integer type.

Definition at line 179 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT64

#define SDL_MAX_UINT64   ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */

An unsigned 64-bit integer type.

Definition at line 192 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MAX_UINT8

#define SDL_MAX_UINT8   ((Uint8)0xFF) /* 255 */

An unsigned 8-bit integer type.

Definition at line 155 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_min

◆ SDL_MIN_SINT16

#define SDL_MIN_SINT16   ((Sint16)(~0x7FFF)) /* -32768 */

Definition at line 162 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT32

#define SDL_MIN_SINT32   ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */

Definition at line 174 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT64

#define SDL_MIN_SINT64   ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */

Definition at line 187 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_SINT8

#define SDL_MIN_SINT8   ((Sint8)(~0x7F)) /* -128 */

Definition at line 150 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT16

#define SDL_MIN_UINT16   ((Uint16)0x0000) /* 0 */

Definition at line 168 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT32

#define SDL_MIN_UINT32   ((Uint32)0x00000000) /* 0 */

Definition at line 180 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT64

#define SDL_MIN_UINT64   ((Uint64)(0x0000000000000000ull)) /* 0 */

Definition at line 193 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_MIN_UINT8

#define SDL_MIN_UINT8   ((Uint8)0x00) /* 0 */

Definition at line 156 of file SDL_stdinc.h.

Referenced by TestTypes().

◆ SDL_OUT_BYTECAP

#define SDL_OUT_BYTECAP (   x)

Definition at line 276 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_OUT_CAP

#define SDL_OUT_CAP (   x)

Definition at line 275 of file SDL_stdinc.h.

◆ SDL_OUT_Z_BYTECAP

#define SDL_OUT_Z_BYTECAP (   x)

Definition at line 277 of file SDL_stdinc.h.

◆ SDL_OUT_Z_CAP

#define SDL_OUT_Z_CAP (   x)

Definition at line 274 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_FORMAT_STRING

#define SDL_PRINTF_FORMAT_STRING

Definition at line 278 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRINTF_VARARG_FUNC

#define SDL_PRINTF_VARARG_FUNC (   fmtargnumber)

Definition at line 285 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_PRIs64

◆ SDL_PRIu64

◆ SDL_PRIx64

#define SDL_PRIx64   "I64x"

Definition at line 227 of file SDL_stdinc.h.

Referenced by SDLTest_LogAllocations().

◆ SDL_PRIX64

#define SDL_PRIX64   "I64X"

Definition at line 238 of file SDL_stdinc.h.

Referenced by platform_testEndianessAndSwap(), and TestEndian().

◆ SDL_reinterpret_cast

#define SDL_reinterpret_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 115 of file SDL_stdinc.h.

◆ SDL_SCANF_FORMAT_STRING

#define SDL_SCANF_FORMAT_STRING

Definition at line 279 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_SCANF_VARARG_FUNC

#define SDL_SCANF_VARARG_FUNC (   fmtargnumber)

Definition at line 286 of file SDL_stdinc.h.

Referenced by SDL_memset4().

◆ SDL_stack_alloc

◆ SDL_stack_free

◆ SDL_static_cast

#define SDL_static_cast (   type,
  expression 
)    ((type)(expression))

Definition at line 116 of file SDL_stdinc.h.

Referenced by SDL_memset4(), SDL_Swap16(), SDL_Swap32(), and SDL_Swap64().

◆ SDL_STRINGIFY_ARG

#define SDL_STRINGIFY_ARG (   arg)    #arg

Macro useful for building other macros with strings in them

e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(FUNCTION) ": " X "\n")

Definition at line 101 of file SDL_stdinc.h.

◆ SDL_TABLESIZE

#define SDL_TABLESIZE (   table)    SDL_arraysize(table)

Definition at line 94 of file SDL_stdinc.h.

Referenced by handleKeyboardEvent().

◆ SDL_zero

◆ SDL_zerop

Typedef Documentation

◆ SDL_calloc_func

typedef void*( * SDL_calloc_func) (size_t nmemb, size_t size)

Definition at line 367 of file SDL_stdinc.h.

◆ SDL_free_func

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) void int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool return int return SDL_Joystick return SDL_Joystick return SDL_GameController return return int return int return int return SDL_RWops size_t int return SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation return const char return SDL_Window VkInstance VkSurfaceKHR return SDL_malloc_func SDL_calloc_func SDL_realloc_func SDL_free_func

Definition at line 369 of file SDL_stdinc.h.

◆ SDL_malloc_func

typedef void*( * SDL_malloc_func) (size_t size)

Definition at line 366 of file SDL_stdinc.h.

◆ SDL_realloc_func

typedef void*( * SDL_realloc_func) (void *mem, size_t size)

Definition at line 368 of file SDL_stdinc.h.

◆ Sint16

typedef int16_t Sint16

Definition at line 163 of file SDL_stdinc.h.

◆ Sint32

typedef int32_t Sint32

Definition at line 175 of file SDL_stdinc.h.

◆ Sint64

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) a int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64

Definition at line 188 of file SDL_stdinc.h.

◆ Sint8

typedef int8_t Sint8

Definition at line 151 of file SDL_stdinc.h.

◆ Uint16

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) d int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16

Definition at line 169 of file SDL_stdinc.h.

◆ Uint32

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) e int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32

Definition at line 181 of file SDL_stdinc.h.

◆ Uint64

typedef uint64_t Uint64

Definition at line 194 of file SDL_stdinc.h.

◆ Uint8

SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8

Definition at line 157 of file SDL_stdinc.h.

Enumeration Type Documentation

◆ SDL_bool

enum SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool
Enumerator
SDL_FALSE 
SDL_TRUE 

Definition at line 139 of file SDL_stdinc.h.

140 {
141  SDL_FALSE = 0,
142  SDL_TRUE = 1
143 } SDL_bool;
SDL_bool
Definition: SDL_stdinc.h:139

Function Documentation

◆ SDL_abs()

int SDL_abs ( int  x)

Definition at line 409 of file SDL_stdlib.c.

References SDL_isdigit(), SDL_isspace(), SDL_tolower(), and SDL_toupper().

410 {
411 #if defined(HAVE_ABS)
412  return abs(x);
413 #else
414  return ((x) < 0 ? -(x) : (x));
415 #endif
416 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_acos()

double SDL_acos ( double  x)

Definition at line 75 of file SDL_stdlib.c.

References SDL_atan(), and SDL_sqrt().

Referenced by SDL_acosf(), SDL_asin(), and SDL_memset4().

76 {
77 #if defined(HAVE_ACOS)
78  return acos(val);
79 #else
80  double result;
81  if (val == -1.0) {
82  result = M_PI;
83  } else {
84  result = SDL_atan(SDL_sqrt(1.0 - val * val) / val);
85  if (result < 0.0)
86  {
87  result += M_PI;
88  }
89  }
90  return result;
91 #endif
92 }
GLuint64EXT * result
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:370
double SDL_atan(double x)
Definition: SDL_stdlib.c:35
GLuint GLfloat * val

◆ SDL_acosf()

float SDL_acosf ( float  x)

Definition at line 95 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_memset4().

96 {
97 #if defined(HAVE_ACOSF)
98  return acosf(val);
99 #else
100  return (float)SDL_acos((double)val);
101 #endif
102 }
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
GLuint GLfloat * val

◆ SDL_asin()

double SDL_asin ( double  x)

Definition at line 105 of file SDL_stdlib.c.

References SDL_acos().

Referenced by SDL_asinf(), and SDL_memset4().

106 {
107 #if defined(HAVE_ASIN)
108  return asin(val);
109 #else
110  double result;
111  if (val == -1.0) {
112  result = -(M_PI / 2.0);
113  } else {
114  result = (M_PI / 2.0) - SDL_acos(val);
115  }
116  return result;
117 #endif
118 }
GLuint64EXT * result
double SDL_acos(double val)
Definition: SDL_stdlib.c:75
GLuint GLfloat * val

◆ SDL_asinf()

float SDL_asinf ( float  x)

Definition at line 121 of file SDL_stdlib.c.

References SDL_asin().

Referenced by SDL_memset4().

122 {
123 #if defined(HAVE_ASINF)
124  return asinf(val);
125 #else
126  return (float)SDL_asin((double)val);
127 #endif
128 }
GLuint GLfloat * val
double SDL_asin(double val)
Definition: SDL_stdlib.c:105

◆ SDL_atan()

double SDL_atan ( double  x)

Definition at line 35 of file SDL_stdlib.c.

References atan(), and SDL_uclibc_atan().

Referenced by SDL_acos(), SDL_atanf(), and SDL_memset4().

36 {
37 #if defined(HAVE_ATAN)
38  return atan(x);
39 #else
40  return SDL_uclibc_atan(x);
41 #endif
42 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_atan(double x)
double atan(double x)
Definition: s_atan.c:67

◆ SDL_atan2()

double SDL_atan2 ( double  x,
double  y 
)

Definition at line 55 of file SDL_stdlib.c.

References SDL_uclibc_atan2().

Referenced by SDL_atan2f(), and SDL_memset4().

56 {
57 #if defined(HAVE_ATAN2)
58  return atan2(x, y);
59 #else
60  return SDL_uclibc_atan2(x, y);
61 #endif
62 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_atan2(double y, double x)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_atan2f()

float SDL_atan2f ( float  x,
float  y 
)

Definition at line 65 of file SDL_stdlib.c.

References SDL_atan2().

Referenced by SDL_memset4().

66 {
67 #if defined(HAVE_ATAN2F)
68  return atan2f(x, y);
69 #else
70  return (float)SDL_atan2((double)x, (double)y);
71 #endif
72 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_atan2(double x, double y)
Definition: SDL_stdlib.c:55

◆ SDL_atanf()

float SDL_atanf ( float  x)

Definition at line 45 of file SDL_stdlib.c.

References SDL_atan().

Referenced by SDL_memset4().

46 {
47 #if defined(HAVE_ATANF)
48  return atanf(x);
49 #else
50  return (float)SDL_atan((double)x);
51 #endif
52 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_atan(double x)
Definition: SDL_stdlib.c:35

◆ SDL_atof()

double SDL_atof ( const char *  str)

Definition at line 802 of file SDL_string.c.

References NULL, and SDL_strtod().

Referenced by SDL_memset4().

803 {
804 #ifdef HAVE_ATOF
805  return (double) atof(string);
806 #else
807  return SDL_strtod(string, NULL);
808 #endif /* HAVE_ATOF */
809 }
double SDL_strtod(const char *string, char **endp)
Definition: SDL_string.c:912
#define NULL
Definition: begin_code.h:164

◆ SDL_atoi()

int SDL_atoi ( const char *  str)

Definition at line 793 of file SDL_string.c.

References NULL, and SDL_strtol().

Referenced by SDL_memset4().

794 {
795 #ifdef HAVE_ATOI
796  return atoi(string);
797 #else
798  return SDL_strtol(string, NULL, 0);
799 #endif /* HAVE_ATOI */
800 }
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:812
#define NULL
Definition: begin_code.h:164

◆ SDL_calloc()

void* SDL_calloc ( size_t  nmemb,
size_t  size 
)

Definition at line 5335 of file SDL_malloc.c.

References s_mem, and SDL_AtomicIncRef.

5336 {
5337  void *mem;
5338 
5339  if (!nmemb || !size) {
5340  nmemb = 1;
5341  size = 1;
5342  }
5343 
5344  mem = s_mem.calloc_func(nmemb, size);
5345  if (mem) {
5346  SDL_AtomicIncRef(&s_mem.num_allocations);
5347  }
5348  return mem;
5349 }
static struct @32 s_mem
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:234
GLsizeiptr size

◆ SDL_ceil()

double SDL_ceil ( double  x)

Definition at line 131 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_ceilf(), and SDL_memset4().

132 {
133 #if defined(HAVE_CEIL)
134  return ceil(x);
135 #else
136  double integer = SDL_floor(x);
137  double fraction = x - integer;
138  if (fraction > 0.0) {
139  integer += 1.0;
140  }
141  return integer;
142 #endif /* HAVE_CEIL */
143 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:224

◆ SDL_ceilf()

float SDL_ceilf ( float  x)

Definition at line 146 of file SDL_stdlib.c.

References SDL_ceil().

Referenced by SDL_memset4().

147 {
148 #if defined(HAVE_CEILF)
149  return ceilf(x);
150 #else
151  return (float)SDL_ceil((float)x);
152 #endif
153 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_ceil(double x)
Definition: SDL_stdlib.c:131

◆ SDL_copysign()

double SDL_copysign ( double  x,
double  y 
)

Definition at line 156 of file SDL_stdlib.c.

References copysign(), and SDL_uclibc_copysign().

Referenced by SDL_copysignf(), and SDL_memset4().

157 {
158 #if defined(HAVE_COPYSIGN)
159  return copysign(x, y);
160 #elif defined(HAVE__COPYSIGN)
161  return _copysign(x, y);
162 #elif defined(__WATCOMC__) && defined(__386__)
163  /* this is nasty as hell, but it works.. */
164  unsigned int *xi = (unsigned int *) &x,
165  *yi = (unsigned int *) &y;
166  xi[1] = (yi[1] & 0x80000000) | (xi[1] & 0x7fffffff);
167  return x;
168 #else
169  return SDL_uclibc_copysign(x, y);
170 #endif /* HAVE_COPYSIGN */
171 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_copysign(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double copysign(double x, double y)
Definition: s_copysign.c:21

◆ SDL_copysignf()

float SDL_copysignf ( float  x,
float  y 
)

Definition at line 174 of file SDL_stdlib.c.

References SDL_copysign().

Referenced by SDL_memset4().

175 {
176 #if defined(HAVE_COPYSIGNF)
177  return copysignf(x, y);
178 #else
179  return (float)SDL_copysign((double)x, (double)y);
180 #endif
181 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_copysign(double x, double y)
Definition: SDL_stdlib.c:156

◆ SDL_cos()

double SDL_cos ( double  x)

Definition at line 184 of file SDL_stdlib.c.

References cos(), and SDL_uclibc_cos().

Referenced by SDL_cosf(), and SDL_memset4().

185 {
186 #if defined(HAVE_COS)
187  return cos(x);
188 #else
189  return SDL_uclibc_cos(x);
190 #endif
191 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_cos(double x)
double cos(double x)
Definition: s_cos.c:46

◆ SDL_cosf()

float SDL_cosf ( float  x)

Definition at line 194 of file SDL_stdlib.c.

References SDL_cos().

Referenced by SDL_memset4().

195 {
196 #if defined(HAVE_COSF)
197  return cosf(x);
198 #else
199  return (float)SDL_cos((double)x);
200 #endif
201 }
double SDL_cos(double x)
Definition: SDL_stdlib.c:184
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_fabs()

double SDL_fabs ( double  x)

Definition at line 204 of file SDL_stdlib.c.

References fabs(), and SDL_uclibc_fabs().

Referenced by SDL_fabsf(), and SDL_memset4().

205 {
206 #if defined(HAVE_FABS)
207  return fabs(x);
208 #else
209  return SDL_uclibc_fabs(x);
210 #endif
211 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_fabs(double x)
double fabs(double x)
Definition: s_fabs.c:22

◆ SDL_fabsf()

float SDL_fabsf ( float  x)

Definition at line 214 of file SDL_stdlib.c.

References SDL_fabs().

Referenced by SDL_memset4().

215 {
216 #if defined(HAVE_FABSF)
217  return fabsf(x);
218 #else
219  return (float)SDL_fabs((double)x);
220 #endif
221 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_fabs(double x)
Definition: SDL_stdlib.c:204

◆ SDL_floor()

double SDL_floor ( double  x)

Definition at line 224 of file SDL_stdlib.c.

References floor(), and SDL_uclibc_floor().

Referenced by SDL_ceil(), SDL_floorf(), and SDL_memset4().

225 {
226 #if defined(HAVE_FLOOR)
227  return floor(x);
228 #else
229  return SDL_uclibc_floor(x);
230 #endif
231 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_floor(double x)
double floor(double x)
Definition: s_floor.c:29

◆ SDL_floorf()

float SDL_floorf ( float  x)

Definition at line 234 of file SDL_stdlib.c.

References SDL_floor().

Referenced by SDL_memset4().

235 {
236 #if defined(HAVE_FLOORF)
237  return floorf(x);
238 #else
239  return (float)SDL_floor((double)x);
240 #endif
241 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_floor(double x)
Definition: SDL_stdlib.c:224

◆ SDL_fmod()

double SDL_fmod ( double  x,
double  y 
)

Definition at line 244 of file SDL_stdlib.c.

References SDL_uclibc_fmod().

Referenced by SDL_fmodf(), and SDL_memset4().

245 {
246 #if defined(HAVE_FMOD)
247  return fmod(x, y);
248 #else
249  return SDL_uclibc_fmod(x, y);
250 #endif
251 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_uclibc_fmod(double x, double y)

◆ SDL_fmodf()

float SDL_fmodf ( float  x,
float  y 
)

Definition at line 254 of file SDL_stdlib.c.

References SDL_fmod().

Referenced by SDL_memset4().

255 {
256 #if defined(HAVE_FMODF)
257  return fmodf(x, y);
258 #else
259  return (float)SDL_fmod((double)x, (double)y);
260 #endif
261 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_fmod(double x, double y)
Definition: SDL_stdlib.c:244
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_free()

void SDL_free ( void mem)

Definition at line 5366 of file SDL_malloc.c.

References s_mem, SDL_AtomicDecRef, and void.

5367 {
5368  if (!ptr) {
5369  return;
5370  }
5371 
5372  s_mem.free_func(ptr);
5373  (void)SDL_AtomicDecRef(&s_mem.num_allocations);
5374 }
static struct @32 s_mem
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
#define SDL_AtomicDecRef(a)
Decrement an atomic variable used as a reference count.
Definition: SDL_atomic.h:244

◆ SDL_getenv()

char* SDL_getenv ( const char *  name)

Definition at line 219 of file SDL_getenv.c.

References i, main, NULL, SDL_setenv(), SDL_strcmp, SDL_strlen, and SDL_strncmp.

Referenced by SDL_setenv().

220 {
221  int len, i;
222  char *value;
223 
224  /* Input validation */
225  if (!name || SDL_strlen(name)==0) {
226  return NULL;
227  }
228 
229  value = (char *) 0;
230  if (SDL_env) {
231  len = SDL_strlen(name);
232  for (i = 0; SDL_env[i] && !value; ++i) {
233  if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
234  (SDL_env[i][len] == '=')) {
235  value = &SDL_env[i][len + 1];
236  }
237  }
238  }
239  return value;
240 }
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:108
GLenum GLsizei len
GLuint const GLchar * name
GLsizei const GLfloat * value
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
#define SDL_strlen

◆ SDL_GetMemoryFunctions()

void SDL_GetMemoryFunctions ( SDL_malloc_func malloc_func,
SDL_calloc_func calloc_func,
SDL_realloc_func realloc_func,
SDL_free_func free_func 
)

Get the current set of SDL memory functions.

Definition at line 5271 of file SDL_malloc.c.

References s_mem.

5275 {
5276  if (malloc_func) {
5277  *malloc_func = s_mem.malloc_func;
5278  }
5279  if (calloc_func) {
5280  *calloc_func = s_mem.calloc_func;
5281  }
5282  if (realloc_func) {
5283  *realloc_func = s_mem.realloc_func;
5284  }
5285  if (free_func) {
5286  *free_func = s_mem.free_func;
5287  }
5288 }
static struct @32 s_mem
SDL_realloc_func realloc_func
Definition: SDL_malloc.c:5264
SDL_malloc_func malloc_func
Definition: SDL_malloc.c:5262
SDL_free_func free_func
Definition: SDL_malloc.c:5265
SDL_calloc_func calloc_func
Definition: SDL_malloc.c:5263

◆ SDL_GetNumAllocations()

int SDL_GetNumAllocations ( void  )

Get the number of outstanding (unfreed) allocations.

Definition at line 5315 of file SDL_malloc.c.

References s_mem, and SDL_AtomicGet.

5316 {
5317  return SDL_AtomicGet(&s_mem.num_allocations);
5318 }
static struct @32 s_mem
#define SDL_AtomicGet

◆ SDL_iconv()

size_t SDL_iconv ( SDL_iconv_t  cd,
const char **  inbuf,
size_t inbytesleft,
char **  outbuf,
size_t outbytesleft 
)

Definition at line 248 of file SDL_iconv.c.

References ENCODING_ASCII, ENCODING_LATIN1, ENCODING_UCS2BE, ENCODING_UCS2LE, ENCODING_UCS4BE, ENCODING_UCS4LE, ENCODING_UTF16, ENCODING_UTF16BE, ENCODING_UTF16LE, ENCODING_UTF16NATIVE, ENCODING_UTF32, ENCODING_UTF32BE, ENCODING_UTF32LE, ENCODING_UTF32NATIVE, ENCODING_UTF8, SDL_FALSE, SDL_ICONV_E2BIG, SDL_ICONV_EINVAL, SDL_TRUE, UNICODE_BOM, UNKNOWN_ASCII, and UNKNOWN_UNICODE.

Referenced by SDL_iconv_string().

251 {
252  /* For simplicity, we'll convert everything to and from UCS-4 */
253  const char *src;
254  char *dst;
255  size_t srclen, dstlen;
256  Uint32 ch = 0;
257  size_t total;
258 
259  if (!inbuf || !*inbuf) {
260  /* Reset the context */
261  return 0;
262  }
263  if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) {
264  return SDL_ICONV_E2BIG;
265  }
266  src = *inbuf;
267  srclen = (inbytesleft ? *inbytesleft : 0);
268  dst = *outbuf;
269  dstlen = *outbytesleft;
270 
271  switch (cd->src_fmt) {
272  case ENCODING_UTF16:
273  /* Scan for a byte order marker */
274  {
275  Uint8 *p = (Uint8 *) src;
276  size_t n = srclen / 2;
277  while (n) {
278  if (p[0] == 0xFF && p[1] == 0xFE) {
279  cd->src_fmt = ENCODING_UTF16BE;
280  break;
281  } else if (p[0] == 0xFE && p[1] == 0xFF) {
282  cd->src_fmt = ENCODING_UTF16LE;
283  break;
284  }
285  p += 2;
286  --n;
287  }
288  if (n == 0) {
289  /* We can't tell, default to host order */
290  cd->src_fmt = ENCODING_UTF16NATIVE;
291  }
292  }
293  break;
294  case ENCODING_UTF32:
295  /* Scan for a byte order marker */
296  {
297  Uint8 *p = (Uint8 *) src;
298  size_t n = srclen / 4;
299  while (n) {
300  if (p[0] == 0xFF && p[1] == 0xFE &&
301  p[2] == 0x00 && p[3] == 0x00) {
302  cd->src_fmt = ENCODING_UTF32BE;
303  break;
304  } else if (p[0] == 0x00 && p[1] == 0x00 &&
305  p[2] == 0xFE && p[3] == 0xFF) {
306  cd->src_fmt = ENCODING_UTF32LE;
307  break;
308  }
309  p += 4;
310  --n;
311  }
312  if (n == 0) {
313  /* We can't tell, default to host order */
314  cd->src_fmt = ENCODING_UTF32NATIVE;
315  }
316  }
317  break;
318  }
319 
320  switch (cd->dst_fmt) {
321  case ENCODING_UTF16:
322  /* Default to host order, need to add byte order marker */
323  if (dstlen < 2) {
324  return SDL_ICONV_E2BIG;
325  }
326  *(Uint16 *) dst = UNICODE_BOM;
327  dst += 2;
328  dstlen -= 2;
329  cd->dst_fmt = ENCODING_UTF16NATIVE;
330  break;
331  case ENCODING_UTF32:
332  /* Default to host order, need to add byte order marker */
333  if (dstlen < 4) {
334  return SDL_ICONV_E2BIG;
335  }
336  *(Uint32 *) dst = UNICODE_BOM;
337  dst += 4;
338  dstlen -= 4;
339  cd->dst_fmt = ENCODING_UTF32NATIVE;
340  break;
341  }
342 
343  total = 0;
344  while (srclen > 0) {
345  /* Decode a character */
346  switch (cd->src_fmt) {
347  case ENCODING_ASCII:
348  {
349  Uint8 *p = (Uint8 *) src;
350  ch = (Uint32) (p[0] & 0x7F);
351  ++src;
352  --srclen;
353  }
354  break;
355  case ENCODING_LATIN1:
356  {
357  Uint8 *p = (Uint8 *) src;
358  ch = (Uint32) p[0];
359  ++src;
360  --srclen;
361  }
362  break;
363  case ENCODING_UTF8: /* RFC 3629 */
364  {
365  Uint8 *p = (Uint8 *) src;
366  size_t left = 0;
367  SDL_bool overlong = SDL_FALSE;
368  if (p[0] >= 0xFC) {
369  if ((p[0] & 0xFE) != 0xFC) {
370  /* Skip illegal sequences
371  return SDL_ICONV_EILSEQ;
372  */
373  ch = UNKNOWN_UNICODE;
374  } else {
375  if (p[0] == 0xFC && srclen > 1 && (p[1] & 0xFC) == 0x80) {
376  overlong = SDL_TRUE;
377  }
378  ch = (Uint32) (p[0] & 0x01);
379  left = 5;
380  }
381  } else if (p[0] >= 0xF8) {
382  if ((p[0] & 0xFC) != 0xF8) {
383  /* Skip illegal sequences
384  return SDL_ICONV_EILSEQ;
385  */
386  ch = UNKNOWN_UNICODE;
387  } else {
388  if (p[0] == 0xF8 && srclen > 1 && (p[1] & 0xF8) == 0x80) {
389  overlong = SDL_TRUE;
390  }
391  ch = (Uint32) (p[0] & 0x03);
392  left = 4;
393  }
394  } else if (p[0] >= 0xF0) {
395  if ((p[0] & 0xF8) != 0xF0) {
396  /* Skip illegal sequences
397  return SDL_ICONV_EILSEQ;
398  */
399  ch = UNKNOWN_UNICODE;
400  } else {
401  if (p[0] == 0xF0 && srclen > 1 && (p[1] & 0xF0) == 0x80) {
402  overlong = SDL_TRUE;
403  }
404  ch = (Uint32) (p[0] & 0x07);
405  left = 3;
406  }
407  } else if (p[0] >= 0xE0) {
408  if ((p[0] & 0xF0) != 0xE0) {
409  /* Skip illegal sequences
410  return SDL_ICONV_EILSEQ;
411  */
412  ch = UNKNOWN_UNICODE;
413  } else {
414  if (p[0] == 0xE0 && srclen > 1 && (p[1] & 0xE0) == 0x80) {
415  overlong = SDL_TRUE;
416  }
417  ch = (Uint32) (p[0] & 0x0F);
418  left = 2;
419  }
420  } else if (p[0] >= 0xC0) {
421  if ((p[0] & 0xE0) != 0xC0) {
422  /* Skip illegal sequences
423  return SDL_ICONV_EILSEQ;
424  */
425  ch = UNKNOWN_UNICODE;
426  } else {
427  if ((p[0] & 0xDE) == 0xC0) {
428  overlong = SDL_TRUE;
429  }
430  ch = (Uint32) (p[0] & 0x1F);
431  left = 1;
432  }
433  } else {
434  if ((p[0] & 0x80) != 0x00) {
435  /* Skip illegal sequences
436  return SDL_ICONV_EILSEQ;
437  */
438  ch = UNKNOWN_UNICODE;
439  } else {
440  ch = (Uint32) p[0];
441  }
442  }
443  ++src;
444  --srclen;
445  if (srclen < left) {
446  return SDL_ICONV_EINVAL;
447  }
448  while (left--) {
449  ++p;
450  if ((p[0] & 0xC0) != 0x80) {
451  /* Skip illegal sequences
452  return SDL_ICONV_EILSEQ;
453  */
454  ch = UNKNOWN_UNICODE;
455  break;
456  }
457  ch <<= 6;
458  ch |= (p[0] & 0x3F);
459  ++src;
460  --srclen;
461  }
462  if (overlong) {
463  /* Potential security risk
464  return SDL_ICONV_EILSEQ;
465  */
466  ch = UNKNOWN_UNICODE;
467  }
468  if ((ch >= 0xD800 && ch <= 0xDFFF) ||
469  (ch == 0xFFFE || ch == 0xFFFF) || ch > 0x10FFFF) {
470  /* Skip illegal sequences
471  return SDL_ICONV_EILSEQ;
472  */
473  ch = UNKNOWN_UNICODE;
474  }
475  }
476  break;
477  case ENCODING_UTF16BE: /* RFC 2781 */
478  {
479  Uint8 *p = (Uint8 *) src;
480  Uint16 W1, W2;
481  if (srclen < 2) {
482  return SDL_ICONV_EINVAL;
483  }
484  W1 = ((Uint16) p[0] << 8) | (Uint16) p[1];
485  src += 2;
486  srclen -= 2;
487  if (W1 < 0xD800 || W1 > 0xDFFF) {
488  ch = (Uint32) W1;
489  break;
490  }
491  if (W1 > 0xDBFF) {
492  /* Skip illegal sequences
493  return SDL_ICONV_EILSEQ;
494  */
495  ch = UNKNOWN_UNICODE;
496  break;
497  }
498  if (srclen < 2) {
499  return SDL_ICONV_EINVAL;
500  }
501  p = (Uint8 *) src;
502  W2 = ((Uint16) p[0] << 8) | (Uint16) p[1];
503  src += 2;
504  srclen -= 2;
505  if (W2 < 0xDC00 || W2 > 0xDFFF) {
506  /* Skip illegal sequences
507  return SDL_ICONV_EILSEQ;
508  */
509  ch = UNKNOWN_UNICODE;
510  break;
511  }
512  ch = (((Uint32) (W1 & 0x3FF) << 10) |
513  (Uint32) (W2 & 0x3FF)) + 0x10000;
514  }
515  break;
516  case ENCODING_UTF16LE: /* RFC 2781 */
517  {
518  Uint8 *p = (Uint8 *) src;
519  Uint16 W1, W2;
520  if (srclen < 2) {
521  return SDL_ICONV_EINVAL;
522  }
523  W1 = ((Uint16) p[1] << 8) | (Uint16) p[0];
524  src += 2;
525  srclen -= 2;
526  if (W1 < 0xD800 || W1 > 0xDFFF) {
527  ch = (Uint32) W1;
528  break;
529  }
530  if (W1 > 0xDBFF) {
531  /* Skip illegal sequences
532  return SDL_ICONV_EILSEQ;
533  */
534  ch = UNKNOWN_UNICODE;
535  break;
536  }
537  if (srclen < 2) {
538  return SDL_ICONV_EINVAL;
539  }
540  p = (Uint8 *) src;
541  W2 = ((Uint16) p[1] << 8) | (Uint16) p[0];
542  src += 2;
543  srclen -= 2;
544  if (W2 < 0xDC00 || W2 > 0xDFFF) {
545  /* Skip illegal sequences
546  return SDL_ICONV_EILSEQ;
547  */
548  ch = UNKNOWN_UNICODE;
549  break;
550  }
551  ch = (((Uint32) (W1 & 0x3FF) << 10) |
552  (Uint32) (W2 & 0x3FF)) + 0x10000;
553  }
554  break;
555  case ENCODING_UCS2LE:
556  {
557  Uint8 *p = (Uint8 *) src;
558  if (srclen < 2) {
559  return SDL_ICONV_EINVAL;
560  }
561  ch = ((Uint32) p[1] << 8) | (Uint32) p[0];
562  src += 2;
563  srclen -= 2;
564  }
565  break;
566  case ENCODING_UCS2BE:
567  {
568  Uint8 *p = (Uint8 *) src;
569  if (srclen < 2) {
570  return SDL_ICONV_EINVAL;
571  }
572  ch = ((Uint32) p[0] << 8) | (Uint32) p[1];
573  src += 2;
574  srclen -= 2;
575  }
576  break;
577  case ENCODING_UCS4BE:
578  case ENCODING_UTF32BE:
579  {
580  Uint8 *p = (Uint8 *) src;
581  if (srclen < 4) {
582  return SDL_ICONV_EINVAL;
583  }
584  ch = ((Uint32) p[0] << 24) |
585  ((Uint32) p[1] << 16) |
586  ((Uint32) p[2] << 8) | (Uint32) p[3];
587  src += 4;
588  srclen -= 4;
589  }
590  break;
591  case ENCODING_UCS4LE:
592  case ENCODING_UTF32LE:
593  {
594  Uint8 *p = (Uint8 *) src;
595  if (srclen < 4) {
596  return SDL_ICONV_EINVAL;
597  }
598  ch = ((Uint32) p[3] << 24) |
599  ((Uint32) p[2] << 16) |
600  ((Uint32) p[1] << 8) | (Uint32) p[0];
601  src += 4;
602  srclen -= 4;
603  }
604  break;
605  }
606 
607  /* Encode a character */
608  switch (cd->dst_fmt) {
609  case ENCODING_ASCII:
610  {
611  Uint8 *p = (Uint8 *) dst;
612  if (dstlen < 1) {
613  return SDL_ICONV_E2BIG;
614  }
615  if (ch > 0x7F) {
616  *p = UNKNOWN_ASCII;
617  } else {
618  *p = (Uint8) ch;
619  }
620  ++dst;
621  --dstlen;
622  }
623  break;
624  case ENCODING_LATIN1:
625  {
626  Uint8 *p = (Uint8 *) dst;
627  if (dstlen < 1) {
628  return SDL_ICONV_E2BIG;
629  }
630  if (ch > 0xFF) {
631  *p = UNKNOWN_ASCII;
632  } else {
633  *p = (Uint8) ch;
634  }
635  ++dst;
636  --dstlen;
637  }
638  break;
639  case ENCODING_UTF8: /* RFC 3629 */
640  {
641  Uint8 *p = (Uint8 *) dst;
642  if (ch > 0x10FFFF) {
643  ch = UNKNOWN_UNICODE;
644  }
645  if (ch <= 0x7F) {
646  if (dstlen < 1) {
647  return SDL_ICONV_E2BIG;
648  }
649  *p = (Uint8) ch;
650  ++dst;
651  --dstlen;
652  } else if (ch <= 0x7FF) {
653  if (dstlen < 2) {
654  return SDL_ICONV_E2BIG;
655  }
656  p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F);
657  p[1] = 0x80 | (Uint8) (ch & 0x3F);
658  dst += 2;
659  dstlen -= 2;
660  } else if (ch <= 0xFFFF) {
661  if (dstlen < 3) {
662  return SDL_ICONV_E2BIG;
663  }
664  p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F);
665  p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
666  p[2] = 0x80 | (Uint8) (ch & 0x3F);
667  dst += 3;
668  dstlen -= 3;
669  } else if (ch <= 0x1FFFFF) {
670  if (dstlen < 4) {
671  return SDL_ICONV_E2BIG;
672  }
673  p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07);
674  p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
675  p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
676  p[3] = 0x80 | (Uint8) (ch & 0x3F);
677  dst += 4;
678  dstlen -= 4;
679  } else if (ch <= 0x3FFFFFF) {
680  if (dstlen < 5) {
681  return SDL_ICONV_E2BIG;
682  }
683  p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03);
684  p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
685  p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
686  p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
687  p[4] = 0x80 | (Uint8) (ch & 0x3F);
688  dst += 5;
689  dstlen -= 5;
690  } else {
691  if (dstlen < 6) {
692  return SDL_ICONV_E2BIG;
693  }
694  p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01);
695  p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F);
696  p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F);
697  p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F);
698  p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F);
699  p[5] = 0x80 | (Uint8) (ch & 0x3F);
700  dst += 6;
701  dstlen -= 6;
702  }
703  }
704  break;
705  case ENCODING_UTF16BE: /* RFC 2781 */
706  {
707  Uint8 *p = (Uint8 *) dst;
708  if (ch > 0x10FFFF) {
709  ch = UNKNOWN_UNICODE;
710  }
711  if (ch < 0x10000) {
712  if (dstlen < 2) {
713  return SDL_ICONV_E2BIG;
714  }
715  p[0] = (Uint8) (ch >> 8);
716  p[1] = (Uint8) ch;
717  dst += 2;
718  dstlen -= 2;
719  } else {
720  Uint16 W1, W2;
721  if (dstlen < 4) {
722  return SDL_ICONV_E2BIG;
723  }
724  ch = ch - 0x10000;
725  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
726  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
727  p[0] = (Uint8) (W1 >> 8);
728  p[1] = (Uint8) W1;
729  p[2] = (Uint8) (W2 >> 8);
730  p[3] = (Uint8) W2;
731  dst += 4;
732  dstlen -= 4;
733  }
734  }
735  break;
736  case ENCODING_UTF16LE: /* RFC 2781 */
737  {
738  Uint8 *p = (Uint8 *) dst;
739  if (ch > 0x10FFFF) {
740  ch = UNKNOWN_UNICODE;
741  }
742  if (ch < 0x10000) {
743  if (dstlen < 2) {
744  return SDL_ICONV_E2BIG;
745  }
746  p[1] = (Uint8) (ch >> 8);
747  p[0] = (Uint8) ch;
748  dst += 2;
749  dstlen -= 2;
750  } else {
751  Uint16 W1, W2;
752  if (dstlen < 4) {
753  return SDL_ICONV_E2BIG;
754  }
755  ch = ch - 0x10000;
756  W1 = 0xD800 | (Uint16) ((ch >> 10) & 0x3FF);
757  W2 = 0xDC00 | (Uint16) (ch & 0x3FF);
758  p[1] = (Uint8) (W1 >> 8);
759  p[0] = (Uint8) W1;
760  p[3] = (Uint8) (W2 >> 8);
761  p[2] = (Uint8) W2;
762  dst += 4;
763  dstlen -= 4;
764  }
765  }
766  break;
767  case ENCODING_UCS2BE:
768  {
769  Uint8 *p = (Uint8 *) dst;
770  if (ch > 0xFFFF) {
771  ch = UNKNOWN_UNICODE;
772  }
773  if (dstlen < 2) {
774  return SDL_ICONV_E2BIG;
775  }
776  p[0] = (Uint8) (ch >> 8);
777  p[1] = (Uint8) ch;
778  dst += 2;
779  dstlen -= 2;
780  }
781  break;
782  case ENCODING_UCS2LE:
783  {
784  Uint8 *p = (Uint8 *) dst;
785  if (ch > 0xFFFF) {
786  ch = UNKNOWN_UNICODE;
787  }
788  if (dstlen < 2) {
789  return SDL_ICONV_E2BIG;
790  }
791  p[1] = (Uint8) (ch >> 8);
792  p[0] = (Uint8) ch;
793  dst += 2;
794  dstlen -= 2;
795  }
796  break;
797  case ENCODING_UTF32BE:
798  if (ch > 0x10FFFF) {
799  ch = UNKNOWN_UNICODE;
800  }
801  /* fallthrough */
802  case ENCODING_UCS4BE:
803  if (ch > 0x7FFFFFFF) {
804  ch = UNKNOWN_UNICODE;
805  }
806  {
807  Uint8 *p = (Uint8 *) dst;
808  if (dstlen < 4) {
809  return SDL_ICONV_E2BIG;
810  }
811  p[0] = (Uint8) (ch >> 24);
812  p[1] = (Uint8) (ch >> 16);
813  p[2] = (Uint8) (ch >> 8);
814  p[3] = (Uint8) ch;
815  dst += 4;
816  dstlen -= 4;
817  }
818  break;
819  case ENCODING_UTF32LE:
820  if (ch > 0x10FFFF) {
821  ch = UNKNOWN_UNICODE;
822  }
823  /* fallthrough */
824  case ENCODING_UCS4LE:
825  if (ch > 0x7FFFFFFF) {
826  ch = UNKNOWN_UNICODE;
827  }
828  {
829  Uint8 *p = (Uint8 *) dst;
830  if (dstlen < 4) {
831  return SDL_ICONV_E2BIG;
832  }
833  p[3] = (Uint8) (ch >> 24);
834  p[2] = (Uint8) (ch >> 16);
835  p[1] = (Uint8) (ch >> 8);
836  p[0] = (Uint8) ch;
837  dst += 4;
838  dstlen -= 4;
839  }
840  break;
841  }
842 
843  /* Update state */
844  *inbuf = src;
845  *inbytesleft = srclen;
846  *outbuf = dst;
847  *outbytesleft = dstlen;
848  ++total;
849  }
850  return total;
851 }
GLenum GLenum dst
#define UNKNOWN_UNICODE
Definition: SDL_iconv.c:98
GLfloat GLfloat p
uint32_t Uint32
Definition: SDL_stdinc.h:181
GLenum src
#define UNICODE_BOM
Definition: SDL_iconv.c:95
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:540
#define ENCODING_UTF32NATIVE
Definition: SDL_iconv.c:119
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:542
SDL_bool
Definition: SDL_stdinc.h:139
#define UNKNOWN_ASCII
Definition: SDL_iconv.c:97
GLdouble n
uint16_t Uint16
Definition: SDL_stdinc.h:169
#define ENCODING_UTF16NATIVE
Definition: SDL_iconv.c:118
GLint left

◆ SDL_iconv_close()

int SDL_iconv_close ( SDL_iconv_t  cd)

Definition at line 854 of file SDL_iconv.c.

References SDL_free.

Referenced by SDL_iconv_string().

855 {
856  if (cd != (SDL_iconv_t)-1) {
857  SDL_free(cd);
858  }
859  return 0;
860 }
#define SDL_free

◆ SDL_iconv_open()

SDL_iconv_t SDL_iconv_open ( const char *  tocode,
const char *  fromcode 
)

Definition at line 208 of file SDL_iconv.c.

References SDL_iconv_t::dst_fmt, ENCODING_UNKNOWN, encodings, getlocale(), i, SDL_arraysize, SDL_malloc, SDL_strcasecmp, and SDL_iconv_t::src_fmt.

Referenced by SDL_iconv_string().

209 {
210  int src_fmt = ENCODING_UNKNOWN;
211  int dst_fmt = ENCODING_UNKNOWN;
212  int i;
213  char fromcode_buffer[64];
214  char tocode_buffer[64];
215 
216  if (!fromcode || !*fromcode) {
217  fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer));
218  }
219  if (!tocode || !*tocode) {
220  tocode = getlocale(tocode_buffer, sizeof(tocode_buffer));
221  }
222  for (i = 0; i < SDL_arraysize(encodings); ++i) {
223  if (SDL_strcasecmp(fromcode, encodings[i].name) == 0) {
224  src_fmt = encodings[i].format;
225  if (dst_fmt != ENCODING_UNKNOWN) {
226  break;
227  }
228  }
229  if (SDL_strcasecmp(tocode, encodings[i].name) == 0) {
230  dst_fmt = encodings[i].format;
231  if (src_fmt != ENCODING_UNKNOWN) {
232  break;
233  }
234  }
235  }
236  if (src_fmt != ENCODING_UNKNOWN && dst_fmt != ENCODING_UNKNOWN) {
237  SDL_iconv_t cd = (SDL_iconv_t) SDL_malloc(sizeof(*cd));
238  if (cd) {
239  cd->src_fmt = src_fmt;
240  cd->dst_fmt = dst_fmt;
241  return cd;
242  }
243  }
244  return (SDL_iconv_t) - 1;
245 }
static struct @31 encodings[]
#define SDL_strcasecmp
GLuint const GLchar * name
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:93
#define SDL_malloc
static const char * getlocale(char *buffer, size_t bufsize)
Definition: SDL_iconv.c:173

◆ SDL_iconv_string()

char* SDL_iconv_string ( const char *  tocode,
const char *  fromcode,
const char *  inbuf,
size_t  inbytesleft 
)

This function converts a string between encodings in one pass, returning a string that must be freed with SDL_free() or NULL on error.

Definition at line 865 of file SDL_iconv.c.

References NULL, SDL_iconv(), SDL_iconv_close(), SDL_ICONV_E2BIG, SDL_ICONV_EILSEQ, SDL_ICONV_EINVAL, SDL_ICONV_ERROR, SDL_iconv_open(), SDL_malloc, SDL_memset, and SDL_realloc.

867 {
868  SDL_iconv_t cd;
869  char *string;
870  size_t stringsize;
871  char *outbuf;
872  size_t outbytesleft;
873  size_t retCode = 0;
874 
875  cd = SDL_iconv_open(tocode, fromcode);
876  if (cd == (SDL_iconv_t) - 1) {
877  /* See if we can recover here (fixes iconv on Solaris 11) */
878  if (!tocode || !*tocode) {
879  tocode = "UTF-8";
880  }
881  if (!fromcode || !*fromcode) {
882  fromcode = "UTF-8";
883  }
884  cd = SDL_iconv_open(tocode, fromcode);
885  }
886  if (cd == (SDL_iconv_t) - 1) {
887  return NULL;
888  }
889 
890  stringsize = inbytesleft > 4 ? inbytesleft : 4;
891  string = SDL_malloc(stringsize);
892  if (!string) {
893  SDL_iconv_close(cd);
894  return NULL;
895  }
896  outbuf = string;
897  outbytesleft = stringsize;
898  SDL_memset(outbuf, 0, 4);
899 
900  while (inbytesleft > 0) {
901  retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
902  switch (retCode) {
903  case SDL_ICONV_E2BIG:
904  {
905  char *oldstring = string;
906  stringsize *= 2;
907  string = SDL_realloc(string, stringsize);
908  if (!string) {
909  SDL_iconv_close(cd);
910  return NULL;
911  }
912  outbuf = string + (outbuf - oldstring);
913  outbytesleft = stringsize - (outbuf - string);
914  SDL_memset(outbuf, 0, 4);
915  }
916  break;
917  case SDL_ICONV_EILSEQ:
918  /* Try skipping some input data - not perfect, but... */
919  ++inbuf;
920  --inbytesleft;
921  break;
922  case SDL_ICONV_EINVAL:
923  case SDL_ICONV_ERROR:
924  /* We can't continue... */
925  inbytesleft = 0;
926  break;
927  }
928  }
929  SDL_iconv_close(cd);
930 
931  return string;
932 }
int SDL_iconv_close(SDL_iconv_t cd)
Definition: SDL_iconv.c:854
GLsizei const GLchar *const * string
#define SDL_ICONV_EILSEQ
Definition: SDL_stdinc.h:541
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
Definition: SDL_iconv.c:208
#define SDL_realloc
#define SDL_ICONV_E2BIG
Definition: SDL_stdinc.h:540
#define SDL_ICONV_EINVAL
Definition: SDL_stdinc.h:542
#define NULL
Definition: begin_code.h:164
#define SDL_ICONV_ERROR
Definition: SDL_stdinc.h:539
#define SDL_malloc
size_t SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: SDL_iconv.c:248
#define SDL_memset

◆ SDL_isdigit()

int SDL_isdigit ( int  x)

Definition at line 424 of file SDL_stdlib.c.

Referenced by SDL_abs().

424 { return ((x) >= '0') && ((x) <= '9'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_isspace()

int SDL_isspace ( int  x)

Definition at line 425 of file SDL_stdlib.c.

Referenced by SDL_abs().

425 { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_itoa()

char* SDL_itoa ( int  value,
char *  str,
int  radix 
)

Definition at line 686 of file SDL_string.c.

References SDL_ltoa().

Referenced by SDL_memset4().

687 {
688 #ifdef HAVE_ITOA
689  return itoa(value, string, radix);
690 #else
691  return SDL_ltoa((long)value, string, radix);
692 #endif /* HAVE_ITOA */
693 }
GLsizei const GLfloat * value
char * SDL_ltoa(long value, char *string, int radix)
Definition: SDL_string.c:706

◆ SDL_lltoa()

char* SDL_lltoa ( Sint64  value,
char *  str,
int  radix 
)

Definition at line 750 of file SDL_string.c.

References SDL_ulltoa().

Referenced by SDL_memset4(), and SDL_PrintLongLong().

751 {
752 #if defined(HAVE__I64TOA)
753  return _i64toa(value, string, radix);
754 #else
755  char *bufp = string;
756 
757  if (value < 0) {
758  *bufp++ = '-';
759  SDL_ulltoa(-value, bufp, radix);
760  } else {
761  SDL_ulltoa(value, bufp, radix);
762  }
763 
764  return string;
765 #endif /* HAVE__I64TOA */
766 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ulltoa(Uint64 value, char *string, int radix)
Definition: SDL_string.c:769

◆ SDL_log()

double SDL_log ( double  x)

Definition at line 264 of file SDL_stdlib.c.

References SDL_uclibc_log().

Referenced by SDL_logf(), and SDL_memset4().

265 {
266 #if defined(HAVE_LOG)
267  return log(x);
268 #else
269  return SDL_uclibc_log(x);
270 #endif
271 }
double SDL_uclibc_log(double x)
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_log10()

double SDL_log10 ( double  x)

Definition at line 284 of file SDL_stdlib.c.

References SDL_uclibc_log10().

Referenced by SDL_log10f(), and SDL_memset4().

285 {
286 #if defined(HAVE_LOG10)
287  return log10(x);
288 #else
289  return SDL_uclibc_log10(x);
290 #endif
291 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_log10(double x)

◆ SDL_log10f()

float SDL_log10f ( float  x)

Definition at line 294 of file SDL_stdlib.c.

References SDL_log10().

Referenced by SDL_memset4().

295 {
296 #if defined(HAVE_LOG10F)
297  return log10f(x);
298 #else
299  return (float)SDL_log10((double)x);
300 #endif
301 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_log10(double x)
Definition: SDL_stdlib.c:284

◆ SDL_logf()

float SDL_logf ( float  x)

Definition at line 274 of file SDL_stdlib.c.

References SDL_log().

Referenced by SDL_memset4().

275 {
276 #if defined(HAVE_LOGF)
277  return logf(x);
278 #else
279  return (float)SDL_log((double)x);
280 #endif
281 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_log(double x)
Definition: SDL_stdlib.c:264

◆ SDL_ltoa()

char* SDL_ltoa ( long  value,
char *  str,
int  radix 
)

Definition at line 706 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_itoa(), SDL_memset4(), and SDL_PrintLong().

707 {
708 #if defined(HAVE__LTOA)
709  return _ltoa(value, string, radix);
710 #else
711  char *bufp = string;
712 
713  if (value < 0) {
714  *bufp++ = '-';
715  SDL_ultoa(-value, bufp, radix);
716  } else {
717  SDL_ultoa(value, bufp, radix);
718  }
719 
720  return string;
721 #endif /* HAVE__LTOA */
722 }
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:725

◆ SDL_malloc()

void* SDL_malloc ( size_t  size)

Definition at line 5320 of file SDL_malloc.c.

References s_mem, and SDL_AtomicIncRef.

5321 {
5322  void *mem;
5323 
5324  if (!size) {
5325  size = 1;
5326  }
5327 
5328  mem = s_mem.malloc_func(size);
5329  if (mem) {
5330  SDL_AtomicIncRef(&s_mem.num_allocations);
5331  }
5332  return mem;
5333 }
static struct @32 s_mem
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:234
GLsizeiptr size

◆ SDL_memcmp()

int SDL_memcmp ( const void s1,
const void s2,
size_t  len 
)

Definition at line 387 of file SDL_string.c.

Referenced by SDL_memset4().

388 {
389 #if defined(HAVE_MEMCMP)
390  return memcmp(s1, s2, len);
391 #else
392  char *s1p = (char *) s1;
393  char *s2p = (char *) s2;
394  while (len--) {
395  if (*s1p != *s2p) {
396  return (*s1p - *s2p);
397  }
398  ++s1p;
399  ++s2p;
400  }
401  return 0;
402 #endif /* HAVE_MEMCMP */
403 }
GLenum GLsizei len
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1

◆ SDL_memcpy()

void* SDL_memcpy ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 310 of file SDL_string.c.

References memcpy.

Referenced by SDL_memcpy4(), SDL_memset4(), SDL_strdup(), SDL_strlcpy(), SDL_utf8strlcpy(), and SDL_wcslcpy().

311 {
312 #ifdef __GNUC__
313  /* Presumably this is well tuned for speed.
314  On my machine this is twice as fast as the C code below.
315  */
316  return __builtin_memcpy(dst, src, len);
317 #elif defined(HAVE_MEMCPY)
318  return memcpy(dst, src, len);
319 #elif defined(HAVE_BCOPY)
320  bcopy(src, dst, len);
321  return dst;
322 #else
323  /* GCC 4.9.0 with -O3 will generate movaps instructions with the loop
324  using Uint32* pointers, so we need to make sure the pointers are
325  aligned before we loop using them.
326  */
327  if (((intptr_t)src & 0x3) || ((intptr_t)dst & 0x3)) {
328  /* Do an unaligned byte copy */
329  Uint8 *srcp1 = (Uint8 *)src;
330  Uint8 *dstp1 = (Uint8 *)dst;
331 
332  while (len--) {
333  *dstp1++ = *srcp1++;
334  }
335  } else {
336  size_t left = (len % 4);
337  Uint32 *srcp4, *dstp4;
338  Uint8 *srcp1, *dstp1;
339 
340  srcp4 = (Uint32 *) src;
341  dstp4 = (Uint32 *) dst;
342  len /= 4;
343  while (len--) {
344  *dstp4++ = *srcp4++;
345  }
346 
347  srcp1 = (Uint8 *) srcp4;
348  dstp1 = (Uint8 *) dstp4;
349  switch (left) {
350  case 3:
351  *dstp1++ = *srcp1++;
352  case 2:
353  *dstp1++ = *srcp1++;
354  case 1:
355  *dstp1++ = *srcp1++;
356  }
357  }
358  return dst;
359 #endif /* __GNUC__ */
360 }
GLenum GLenum dst
uint32_t Uint32
Definition: SDL_stdinc.h:181
GLenum src
GLenum GLsizei len
uint8_t Uint8
Definition: SDL_stdinc.h:157
#define memcpy
Definition: SDL_malloc.c:622
GLint left

◆ SDL_memcpy4()

SDL_FORCE_INLINE void* SDL_memcpy4 ( SDL_OUT_BYTECAP(dwords *4) void dst,
SDL_IN_BYTECAP(dwords *4) const void src,
size_t  dwords 
)

Definition at line 592 of file SDL_stdinc.h.

References SDL_memcpy().

593 {
594  return SDL_memcpy(dst, src, dwords * 4);
595 }
GLenum GLenum dst
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310
GLenum src

◆ SDL_memmove()

void* SDL_memmove ( SDL_OUT_BYTECAP(len) void dst,
SDL_IN_BYTECAP(len) const void src,
size_t  len 
)

Definition at line 363 of file SDL_string.c.

References memmove.

Referenced by SDL_memset4().

364 {
365 #if defined(HAVE_MEMMOVE)
366  return memmove(dst, src, len);
367 #else
368  char *srcp = (char *) src;
369  char *dstp = (char *) dst;
370 
371  if (src < dst) {
372  srcp += len - 1;
373  dstp += len - 1;
374  while (len--) {
375  *dstp-- = *srcp--;
376  }
377  } else {
378  while (len--) {
379  *dstp++ = *srcp++;
380  }
381  }
382  return dst;
383 #endif /* HAVE_MEMMOVE */
384 }
GLenum GLenum dst
#define memmove
Definition: SDL_qsort.c:59
GLenum src
GLenum GLsizei len

◆ SDL_memset()

void* SDL_memset ( SDL_OUT_BYTECAP(len) void dst,
int  c,
size_t  len 
)

Definition at line 266 of file SDL_string.c.

References memset.

267 {
268 #if defined(HAVE_MEMSET)
269  return memset(dst, c, len);
270 #else
271  size_t left;
272  Uint32 *dstp4;
273  Uint8 *dstp1 = (Uint8 *) dst;
274  Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24));
275  Uint8 value1 = (Uint8) c;
276 
277  /* The destination pointer needs to be aligned on a 4-byte boundary to
278  * execute a 32-bit set. Set first bytes manually if needed until it is
279  * aligned. */
280  while ((intptr_t)dstp1 & 0x3) {
281  if (len--) {
282  *dstp1++ = value1;
283  } else {
284  return dst;
285  }
286  }
287 
288  dstp4 = (Uint32 *) dstp1;
289  left = (len % 4);
290  len /= 4;
291  while (len--) {
292  *dstp4++ = value4;
293  }
294 
295  dstp1 = (Uint8 *) dstp4;
296  switch (left) {
297  case 3:
298  *dstp1++ = value1;
299  case 2:
300  *dstp1++ = value1;
301  case 1:
302  *dstp1++ = value1;
303  }
304 
305  return dst;
306 #endif /* HAVE_MEMSET */
307 }
GLenum GLenum dst
#define memset
Definition: SDL_malloc.c:619
uint32_t Uint32
Definition: SDL_stdinc.h:181
GLenum GLsizei len
uint8_t Uint8
Definition: SDL_stdinc.h:157
const GLubyte * c
GLint left

◆ SDL_memset4()

SDL_FORCE_INLINE void SDL_memset4 ( void dst,
Uint32  val,
size_t  dwords 
)

Definition at line 420 of file SDL_stdinc.h.

References DECLSPEC, SDL_acos(), SDL_acosf(), SDL_asin(), SDL_asinf(), SDL_atan(), SDL_atan2(), SDL_atan2f(), SDL_atanf(), SDL_atof(), SDL_atoi(), SDL_ceil(), SDL_ceilf(), SDL_copysign(), SDL_copysignf(), SDL_cos(), SDL_cosf(), SDL_fabs(), SDL_fabsf(), SDL_floor(), SDL_floorf(), SDL_fmod(), SDL_fmodf(), SDL_IN_BYTECAP, SDL_INOUT_Z_CAP, SDL_itoa(), SDL_lltoa(), SDL_log(), SDL_log10(), SDL_log10f(), SDL_logf(), SDL_ltoa(), SDL_memcmp(), SDL_memcpy(), SDL_memmove(), SDL_OUT_BYTECAP, SDL_OUT_Z_CAP, SDL_pow(), SDL_powf(), SDL_PRINTF_FORMAT_STRING, SDL_PRINTF_VARARG_FUNC, SDL_scalbn(), SDL_scalbnf(), SDL_SCANF_FORMAT_STRING, SDL_SCANF_VARARG_FUNC, SDL_sin(), SDL_sinf(), SDL_snprintf(), SDL_sqrt(), SDL_sqrtf(), SDL_sscanf(), SDL_static_cast, SDL_strcasecmp(), SDL_strchr(), SDL_strcmp(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strlen(), SDL_strlwr(), SDL_strncasecmp(), SDL_strncmp(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtod(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_strupr(), SDL_tan(), SDL_tanf(), SDL_uitoa(), SDL_ulltoa(), SDL_ultoa(), SDL_utf8strlcpy(), SDL_utf8strlen(), SDL_vsnprintf(), SDL_vsscanf(), SDL_wcscmp(), SDL_wcslcat(), SDL_wcslcpy(), SDL_wcslen(), SDLCALL, and text.

Referenced by SDL_FillRect1(), SDL_FillRect2(), and SDL_FillRect4().

421 {
422 #if defined(__GNUC__) && defined(i386)
423  int u0, u1, u2;
424  __asm__ __volatile__ (
425  "cld \n\t"
426  "rep ; stosl \n\t"
427  : "=&D" (u0), "=&a" (u1), "=&c" (u2)
428  : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, dwords))
429  : "memory"
430  );
431 #else
432  size_t _n = (dwords + 3) / 4;
433  Uint32 *_p = SDL_static_cast(Uint32 *, dst);
434  Uint32 _val = (val);
435  if (dwords == 0)
436  return;
437  switch (dwords % 4)
438  {
439  case 0: do { *_p++ = _val; /* fallthrough */
440  case 3: *_p++ = _val; /* fallthrough */
441  case 2: *_p++ = _val; /* fallthrough */
442  case 1: *_p++ = _val; /* fallthrough */
443  } while ( --_n );
444  }
445 #endif
446 }
GLenum GLenum dst
GLfixed u1
uint32_t Uint32
Definition: SDL_stdinc.h:181
GLfixed GLfixed u2
GLuint GLfloat * val
#define SDL_static_cast(type, expression)
Definition: SDL_stdinc.h:116

◆ SDL_pow()

double SDL_pow ( double  x,
double  y 
)

Definition at line 304 of file SDL_stdlib.c.

References SDL_uclibc_pow().

Referenced by SDL_memset4(), and SDL_powf().

305 {
306 #if defined(HAVE_POW)
307  return pow(x, y);
308 #else
309  return SDL_uclibc_pow(x, y);
310 #endif
311 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_pow(double x, double y)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ SDL_powf()

float SDL_powf ( float  x,
float  y 
)

Definition at line 314 of file SDL_stdlib.c.

References SDL_pow().

Referenced by SDL_memset4().

315 {
316 #if defined(HAVE_POWF)
317  return powf(x, y);
318 #else
319  return (float)SDL_pow((double)x, (double)y);
320 #endif
321 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
double SDL_pow(double x, double y)
Definition: SDL_stdlib.c:304

◆ SDL_qsort()

void SDL_qsort ( void base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compare 
)

◆ SDL_realloc()

void* SDL_realloc ( void mem,
size_t  size 
)

Definition at line 5351 of file SDL_malloc.c.

References s_mem, and SDL_AtomicIncRef.

5352 {
5353  void *mem;
5354 
5355  if (!ptr && !size) {
5356  size = 1;
5357  }
5358 
5359  mem = s_mem.realloc_func(ptr, size);
5360  if (mem && !ptr) {
5361  SDL_AtomicIncRef(&s_mem.num_allocations);
5362  }
5363  return mem;
5364 }
static struct @32 s_mem
#define SDL_AtomicIncRef(a)
Increment an atomic variable used as a reference count.
Definition: SDL_atomic.h:234
GLsizeiptr size

◆ SDL_scalbn()

double SDL_scalbn ( double  x,
int  n 
)

Definition at line 324 of file SDL_stdlib.c.

References scalbn, and SDL_uclibc_scalbn().

Referenced by SDL_memset4(), and SDL_scalbnf().

325 {
326 #if defined(HAVE_SCALBN)
327  return scalbn(x, n);
328 #elif defined(HAVE__SCALB)
329  return _scalb(x, n);
330 #elif defined(HAVE_LIBC) && defined(HAVE_FLOAT_H) && (FLT_RADIX == 2)
331 /* from scalbn(3): If FLT_RADIX equals 2 (which is
332  * usual), then scalbn() is equivalent to ldexp(3). */
333  return ldexp(x, n);
334 #else
335  return SDL_uclibc_scalbn(x, n);
336 #endif
337 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
#define scalbn
Definition: math_private.h:45
GLdouble n
double SDL_uclibc_scalbn(double x, int n)

◆ SDL_scalbnf()

float SDL_scalbnf ( float  x,
int  n 
)

Definition at line 340 of file SDL_stdlib.c.

References SDL_scalbn().

Referenced by SDL_memset4().

341 {
342 #if defined(HAVE_SCALBNF)
343  return scalbnf(x, n);
344 #else
345  return (float)SDL_scalbn((double)x, n);
346 #endif
347 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_scalbn(double x, int n)
Definition: SDL_stdlib.c:324
GLdouble n

◆ SDL_setenv()

int SDL_setenv ( const char *  name,
const char *  value,
int  overwrite 
)

Definition at line 110 of file SDL_getenv.c.

References Android_JNI_GetManifestEnvironmentVariables(), i, NULL, SDL_free, SDL_getenv(), SDL_malloc, SDL_realloc, SDL_snprintf, SDL_strchr, SDL_strlen, and SDL_strncmp.

Referenced by SDL_getenv().

111 {
112  int added;
113  int len, i;
114  char **new_env;
115  char *new_variable;
116 
117  /* Input validation */
118  if (!name || SDL_strlen(name) == 0 || SDL_strchr(name, '=') != NULL || !value) {
119  return (-1);
120  }
121 
122  /* See if it already exists */
123  if (!overwrite && SDL_getenv(name)) {
124  return 0;
125  }
126 
127  /* Allocate memory for the variable */
128  len = SDL_strlen(name) + SDL_strlen(value) + 2;
129  new_variable = (char *) SDL_malloc(len);
130  if (!new_variable) {
131  return (-1);
132  }
133 
134  SDL_snprintf(new_variable, len, "%s=%s", name, value);
135  value = new_variable + SDL_strlen(name) + 1;
136  name = new_variable;
137 
138  /* Actually put it into the environment */
139  added = 0;
140  i = 0;
141  if (SDL_env) {
142  /* Check to see if it's already there... */
143  len = (value - name);
144  for (; SDL_env[i]; ++i) {
145  if (SDL_strncmp(SDL_env[i], name, len) == 0) {
146  break;
147  }
148  }
149  /* If we found it, just replace the entry */
150  if (SDL_env[i]) {
151  SDL_free(SDL_env[i]);
152  SDL_env[i] = new_variable;
153  added = 1;
154  }
155  }
156 
157  /* Didn't find it in the environment, expand and add */
158  if (!added) {
159  new_env = SDL_realloc(SDL_env, (i + 2) * sizeof(char *));
160  if (new_env) {
161  SDL_env = new_env;
162  SDL_env[i++] = new_variable;
163  SDL_env[i++] = (char *) 0;
164  added = 1;
165  } else {
166  SDL_free(new_variable);
167  }
168  }
169  return (added ? 0 : -1);
170 }
char * SDL_getenv(const char *name)
Definition: SDL_getenv.c:219
#define SDL_realloc
#define SDL_strncmp
static char ** SDL_env
Definition: SDL_getenv.c:108
GLenum GLsizei len
GLuint const GLchar * name
#define SDL_strchr
#define SDL_free
GLsizei const GLfloat * value
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:164
#define SDL_strlen
#define SDL_snprintf
#define SDL_malloc

◆ SDL_SetMemoryFunctions()

int SDL_SetMemoryFunctions ( SDL_malloc_func  malloc_func,
SDL_calloc_func  calloc_func,
SDL_realloc_func  realloc_func,
SDL_free_func  free_func 
)

Replace SDL's memory allocation functions with a custom set.

Note
If you are replacing SDL's memory functions, you should call SDL_GetNumAllocations() and be very careful if it returns non-zero. That means that your free function will be called with memory allocated by the previous memory allocation functions.

Definition at line 5290 of file SDL_malloc.c.

References calloc_func, free_func, malloc_func, realloc_func, s_mem, and SDL_InvalidParamError.

5294 {
5295  if (!malloc_func) {
5296  return SDL_InvalidParamError("malloc_func");
5297  }
5298  if (!calloc_func) {
5299  return SDL_InvalidParamError("calloc_func");
5300  }
5301  if (!realloc_func) {
5302  return SDL_InvalidParamError("realloc_func");
5303  }
5304  if (!free_func) {
5305  return SDL_InvalidParamError("free_func");
5306  }
5307 
5308  s_mem.malloc_func = malloc_func;
5309  s_mem.calloc_func = calloc_func;
5310  s_mem.realloc_func = realloc_func;
5311  s_mem.free_func = free_func;
5312  return 0;
5313 }
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:54
static struct @32 s_mem
SDL_realloc_func realloc_func
Definition: SDL_malloc.c:5264
SDL_malloc_func malloc_func
Definition: SDL_malloc.c:5262
SDL_free_func free_func
Definition: SDL_malloc.c:5265
SDL_calloc_func calloc_func
Definition: SDL_malloc.c:5263

◆ SDL_sin()

double SDL_sin ( double  x)

Definition at line 350 of file SDL_stdlib.c.

References SDL_uclibc_sin(), and sin().

Referenced by SDL_memset4(), and SDL_sinf().

351 {
352 #if defined(HAVE_SIN)
353  return sin(x);
354 #else
355  return SDL_uclibc_sin(x);
356 #endif
357 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sin(double x)
double sin(double x)
Definition: s_sin.c:46

◆ SDL_sinf()

float SDL_sinf ( float  x)

Definition at line 360 of file SDL_stdlib.c.

References SDL_sin().

Referenced by SDL_memset4().

361 {
362 #if defined(HAVE_SINF)
363  return sinf(x);
364 #else
365  return (float)SDL_sin((double)x);
366 #endif
367 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sin(double x)
Definition: SDL_stdlib.c:350

◆ SDL_snprintf()

int SDL_snprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
SDL_PRINTF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 1310 of file SDL_string.c.

References retval, SDL_OUT_Z_CAP, and SDL_vsnprintf().

Referenced by SDL_memset4().

1311 {
1312  va_list ap;
1313  int retval;
1314 
1315  va_start(ap, fmt);
1316  retval = SDL_vsnprintf(text, maxlen, fmt, ap);
1317  va_end(ap);
1318 
1319  return retval;
1320 }
int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1524
SDL_bool retval
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47

◆ SDL_sqrt()

double SDL_sqrt ( double  x)

Definition at line 370 of file SDL_stdlib.c.

References SDL_uclibc_sqrt().

Referenced by SDL_acos(), SDL_memset4(), and SDL_sqrtf().

371 {
372 #if defined(HAVE_SQRT)
373  return sqrt(x);
374 #else
375  return SDL_uclibc_sqrt(x);
376 #endif
377 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_sqrt(double x)

◆ SDL_sqrtf()

float SDL_sqrtf ( float  x)

Definition at line 380 of file SDL_stdlib.c.

References SDL_sqrt().

Referenced by SDL_memset4().

381 {
382 #if defined(HAVE_SQRTF)
383  return sqrtf(x);
384 #else
385  return (float)SDL_sqrt((double)x);
386 #endif
387 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_sqrt(double x)
Definition: SDL_stdlib.c:370

◆ SDL_sscanf()

int SDL_sscanf ( const char *  text,
SDL_SCANF_FORMAT_STRING const char *  fmt,
  ... 
)

Definition at line 1018 of file SDL_string.c.

References SDL_vsscanf(), and text.

Referenced by SDL_memset4().

1019 {
1020  int rc;
1021  va_list ap;
1022  va_start(ap, fmt);
1023  rc = SDL_vsscanf(text, fmt, ap);
1024  va_end(ap);
1025  return rc;
1026 }
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
Definition: SDL_string.c:1036

◆ SDL_strcasecmp()

int SDL_strcasecmp ( const char *  str1,
const char *  str2 
)

Definition at line 965 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4().

966 {
967 #ifdef HAVE_STRCASECMP
968  return strcasecmp(str1, str2);
969 #elif defined(HAVE__STRICMP)
970  return _stricmp(str1, str2);
971 #else
972  char a = 0;
973  char b = 0;
974  while (*str1 && *str2) {
975  a = SDL_toupper((unsigned char) *str1);
976  b = SDL_toupper((unsigned char) *str2);
977  if (a != b)
978  break;
979  ++str1;
980  ++str2;
981  }
982  a = SDL_toupper(*str1);
983  b = SDL_toupper(*str2);
984  return (int) ((unsigned char) a - (unsigned char) b);
985 #endif /* HAVE_STRCASECMP */
986 }
#define SDL_toupper
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strchr()

char* SDL_strchr ( const char *  str,
int  c 
)

Definition at line 622 of file SDL_string.c.

References NULL, and SDL_const_cast.

Referenced by SDL_memset4().

623 {
624 #ifdef HAVE_STRCHR
625  return SDL_const_cast(char*,strchr(string, c));
626 #elif defined(HAVE_INDEX)
627  return SDL_const_cast(char*,index(string, c));
628 #else
629  while (*string) {
630  if (*string == c) {
631  return (char *) string;
632  }
633  ++string;
634  }
635  return NULL;
636 #endif /* HAVE_STRCHR */
637 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
GLsizei const GLchar *const * string
const GLubyte * c
GLuint index
#define NULL
Definition: begin_code.h:164

◆ SDL_strcmp()

int SDL_strcmp ( const char *  str1,
const char *  str2 
)

Definition at line 929 of file SDL_string.c.

Referenced by SDL_memset4().

930 {
931 #if defined(HAVE_STRCMP)
932  return strcmp(str1, str2);
933 #else
934  while (*str1 && *str2) {
935  if (*str1 != *str2)
936  break;
937  ++str1;
938  ++str2;
939  }
940  return (int)((unsigned char) *str1 - (unsigned char) *str2);
941 #endif /* HAVE_STRCMP */
942 }

◆ SDL_strdup()

char* SDL_strdup ( const char *  str)

Definition at line 562 of file SDL_string.c.

References SDL_malloc, SDL_memcpy(), and SDL_strlen().

Referenced by SDL_memset4().

563 {
564  size_t len = SDL_strlen(string) + 1;
565  char *newstr = SDL_malloc(len);
566  if (newstr) {
567  SDL_memcpy(newstr, string, len);
568  }
569  return newstr;
570 }
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310
#define SDL_malloc

◆ SDL_strlcat()

size_t SDL_strlcat ( SDL_INOUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 547 of file SDL_string.c.

References SDL_strlcpy(), and SDL_strlen().

Referenced by SDL_memset4().

548 {
549 #if defined(HAVE_STRLCAT)
550  return strlcat(dst, src, maxlen);
551 #else
552  size_t dstlen = SDL_strlen(dst);
553  size_t srclen = SDL_strlen(src);
554  if (dstlen < maxlen) {
555  SDL_strlcpy(dst + dstlen, src, maxlen - dstlen);
556  }
557  return dstlen + srclen;
558 #endif /* HAVE_STRLCAT */
559 }
GLenum GLenum dst
size_t SDL_strlcpy(SDL_OUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
Definition: SDL_string.c:481
GLenum src
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406

◆ SDL_strlcpy()

size_t SDL_strlcpy ( SDL_OUT_Z_CAP(maxlen) char *  dst,
const char *  src,
size_t  maxlen 
)

Definition at line 481 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_strlen().

Referenced by SDL_memset4(), SDL_PrintString(), and SDL_strlcat().

482 {
483 #if defined(HAVE_STRLCPY)
484  return strlcpy(dst, src, maxlen);
485 #else
486  size_t srclen = SDL_strlen(src);
487  if (maxlen > 0) {
488  size_t len = SDL_min(srclen, maxlen - 1);
489  SDL_memcpy(dst, src, len);
490  dst[len] = '\0';
491  }
492  return srclen;
493 #endif /* HAVE_STRLCPY */
494 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
GLenum GLenum dst
GLenum src
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310

◆ SDL_strlen()

size_t SDL_strlen ( const char *  str)

Definition at line 406 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_PrintString(), SDL_strdup(), SDL_strlcat(), SDL_strlcpy(), SDL_strrchr(), SDL_strrev(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), and SDL_utf8strlcpy().

407 {
408 #if defined(HAVE_STRLEN)
409  return strlen(string);
410 #else
411  size_t len = 0;
412  while (*string++) {
413  ++len;
414  }
415  return len;
416 #endif /* HAVE_STRLEN */
417 }
GLenum GLsizei len

◆ SDL_strlwr()

char* SDL_strlwr ( char *  str)

Definition at line 607 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4(), and SDL_PrintString().

608 {
609 #if defined(HAVE__STRLWR)
610  return _strlwr(string);
611 #else
612  char *bufp = string;
613  while (*bufp) {
614  *bufp = SDL_tolower((unsigned char) *bufp);
615  ++bufp;
616  }
617  return string;
618 #endif /* HAVE__STRLWR */
619 }
GLsizei const GLchar *const * string
#define SDL_tolower

◆ SDL_strncasecmp()

int SDL_strncasecmp ( const char *  str1,
const char *  str2,
size_t  len 
)

Definition at line 989 of file SDL_string.c.

References SDL_tolower.

Referenced by SDL_memset4().

990 {
991 #ifdef HAVE_STRNCASECMP
992  return strncasecmp(str1, str2, maxlen);
993 #elif defined(HAVE__STRNICMP)
994  return _strnicmp(str1, str2, maxlen);
995 #else
996  char a = 0;
997  char b = 0;
998  while (*str1 && *str2 && maxlen) {
999  a = SDL_tolower((unsigned char) *str1);
1000  b = SDL_tolower((unsigned char) *str2);
1001  if (a != b)
1002  break;
1003  ++str1;
1004  ++str2;
1005  --maxlen;
1006  }
1007  if (maxlen == 0) {
1008  return 0;
1009  } else {
1010  a = SDL_tolower((unsigned char) *str1);
1011  b = SDL_tolower((unsigned char) *str2);
1012  return (int) ((unsigned char) a - (unsigned char) b);
1013  }
1014 #endif /* HAVE_STRNCASECMP */
1015 }
#define SDL_tolower
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strncmp()

int SDL_strncmp ( const char *  str1,
const char *  str2,
size_t  maxlen 
)

Definition at line 945 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strstr(), SDL_strtol(), SDL_strtoll(), SDL_strtoul(), SDL_strtoull(), SDL_vsnprintf(), and SDL_vsscanf().

946 {
947 #if defined(HAVE_STRNCMP)
948  return strncmp(str1, str2, maxlen);
949 #else
950  while (*str1 && *str2 && maxlen) {
951  if (*str1 != *str2)
952  break;
953  ++str1;
954  ++str2;
955  --maxlen;
956  }
957  if (!maxlen) {
958  return 0;
959  }
960  return (int) ((unsigned char) *str1 - (unsigned char) *str2);
961 #endif /* HAVE_STRNCMP */
962 }

◆ SDL_strrchr()

char* SDL_strrchr ( const char *  str,
int  c 
)

Definition at line 640 of file SDL_string.c.

References NULL, SDL_const_cast, and SDL_strlen().

Referenced by SDL_memset4().

641 {
642 #ifdef HAVE_STRRCHR
643  return SDL_const_cast(char*,strrchr(string, c));
644 #elif defined(HAVE_RINDEX)
645  return SDL_const_cast(char*,rindex(string, c));
646 #else
647  const char *bufp = string + SDL_strlen(string) - 1;
648  while (bufp >= string) {
649  if (*bufp == c) {
650  return (char *) bufp;
651  }
652  --bufp;
653  }
654  return NULL;
655 #endif /* HAVE_STRRCHR */
656 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
const GLubyte * c
#define NULL
Definition: begin_code.h:164

◆ SDL_strrev()

char* SDL_strrev ( char *  str)

Definition at line 573 of file SDL_string.c.

References SDL_strlen().

Referenced by SDL_memset4(), SDL_ulltoa(), and SDL_ultoa().

574 {
575 #if defined(HAVE__STRREV)
576  return _strrev(string);
577 #else
578  size_t len = SDL_strlen(string);
579  char *a = &string[0];
580  char *b = &string[len - 1];
581  len /= 2;
582  while (len--) {
583  char c = *a;
584  *a++ = *b;
585  *b-- = c;
586  }
587  return string;
588 #endif /* HAVE__STRREV */
589 }
GLsizei const GLchar *const * string
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
const GLubyte * c
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b

◆ SDL_strstr()

char* SDL_strstr ( const char *  haystack,
const char *  needle 
)

Definition at line 659 of file SDL_string.c.

References NULL, SDL_const_cast, SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

660 {
661 #if defined(HAVE_STRSTR)
662  return SDL_const_cast(char*,strstr(haystack, needle));
663 #else
664  size_t length = SDL_strlen(needle);
665  while (*haystack) {
666  if (SDL_strncmp(haystack, needle, length) == 0) {
667  return (char *) haystack;
668  }
669  ++haystack;
670  }
671  return NULL;
672 #endif /* HAVE_STRSTR */
673 }
#define SDL_const_cast(type, expression)
Definition: SDL_stdinc.h:117
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
#define NULL
Definition: begin_code.h:164
GLuint GLsizei GLsizei * length

◆ SDL_strtod()

double SDL_strtod ( const char *  str,
char **  endp 
)

Definition at line 912 of file SDL_string.c.

References SDL_ScanFloat().

Referenced by SDL_atof(), and SDL_memset4().

913 {
914 #if defined(HAVE_STRTOD)
915  return strtod(string, endp);
916 #else
917  size_t len;
918  double value = 0.0;
919 
920  len = SDL_ScanFloat(string, &value);
921  if (endp) {
922  *endp = (char *) string + len;
923  }
924  return value;
925 #endif /* HAVE_STRTOD */
926 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:231
GLenum GLsizei len
GLsizei const GLfloat * value

◆ SDL_strtol()

long SDL_strtol ( const char *  str,
char **  endp,
int  base 
)

Definition at line 812 of file SDL_string.c.

References SDL_ScanLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_atoi(), SDL_memset4(), and SDL_vsnprintf().

813 {
814 #if defined(HAVE_STRTOL)
815  return strtol(string, endp, base);
816 #else
817  size_t len;
818  long value = 0;
819 
820  if (!base) {
821  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
822  base = 16;
823  } else {
824  base = 10;
825  }
826  }
827 
828  len = SDL_ScanLong(string, base, &value);
829  if (endp) {
830  *endp = (char *) string + len;
831  }
832  return value;
833 #endif /* HAVE_STRTOL */
834 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:53
GLsizei const GLfloat * value

◆ SDL_strtoll()

Sint64 SDL_strtoll ( const char *  str,
char **  endp,
int  base 
)

Definition at line 862 of file SDL_string.c.

References SDL_ScanLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

863 {
864 #if defined(HAVE_STRTOLL)
865  return strtoll(string, endp, base);
866 #else
867  size_t len;
868  Sint64 value = 0;
869 
870  if (!base) {
871  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
872  base = 16;
873  } else {
874  base = 10;
875  }
876  }
877 
878  len = SDL_ScanLongLong(string, base, &value);
879  if (endp) {
880  *endp = (char *) string + len;
881  }
882  return value;
883 #endif /* HAVE_STRTOLL */
884 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:158
int64_t Sint64
Definition: SDL_stdinc.h:188

◆ SDL_strtoul()

unsigned long SDL_strtoul ( const char *  str,
char **  endp,
int  base 
)

Definition at line 837 of file SDL_string.c.

References SDL_ScanUnsignedLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

838 {
839 #if defined(HAVE_STRTOUL)
840  return strtoul(string, endp, base);
841 #else
842  size_t len;
843  unsigned long value = 0;
844 
845  if (!base) {
846  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
847  base = 16;
848  } else {
849  base = 10;
850  }
851  }
852 
853  len = SDL_ScanUnsignedLong(string, base, &value);
854  if (endp) {
855  *endp = (char *) string + len;
856  }
857  return value;
858 #endif /* HAVE_STRTOUL */
859 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:94

◆ SDL_strtoull()

Uint64 SDL_strtoull ( const char *  str,
char **  endp,
int  base 
)

Definition at line 887 of file SDL_string.c.

References SDL_ScanUnsignedLongLong(), SDL_strlen(), and SDL_strncmp().

Referenced by SDL_memset4().

888 {
889 #if defined(HAVE_STRTOULL)
890  return strtoull(string, endp, base);
891 #else
892  size_t len;
893  Uint64 value = 0;
894 
895  if (!base) {
896  if ((SDL_strlen(string) > 2) && (SDL_strncmp(string, "0x", 2) == 0)) {
897  base = 16;
898  } else {
899  base = 10;
900  }
901  }
902 
903  len = SDL_ScanUnsignedLongLong(string, base, &value);
904  if (endp) {
905  *endp = (char *) string + len;
906  }
907  return value;
908 #endif /* HAVE_STRTOULL */
909 }
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
uint64_t Uint64
Definition: SDL_stdinc.h:194
GLenum GLsizei len
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
GLsizei const GLfloat * value
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:199

◆ SDL_strupr()

char* SDL_strupr ( char *  str)

Definition at line 592 of file SDL_string.c.

References SDL_toupper.

Referenced by SDL_memset4(), and SDL_PrintString().

593 {
594 #if defined(HAVE__STRUPR)
595  return _strupr(string);
596 #else
597  char *bufp = string;
598  while (*bufp) {
599  *bufp = SDL_toupper((unsigned char) *bufp);
600  ++bufp;
601  }
602  return string;
603 #endif /* HAVE__STRUPR */
604 }
GLsizei const GLchar *const * string
#define SDL_toupper

◆ SDL_tan()

double SDL_tan ( double  x)

Definition at line 390 of file SDL_stdlib.c.

References SDL_uclibc_tan(), and tan().

Referenced by SDL_memset4(), and SDL_tanf().

391 {
392 #if defined(HAVE_TAN)
393  return tan(x);
394 #else
395  return SDL_uclibc_tan(x);
396 #endif
397 }
double tan(double x)
Definition: s_tan.c:45
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_uclibc_tan(double x)

◆ SDL_tanf()

float SDL_tanf ( float  x)

Definition at line 400 of file SDL_stdlib.c.

References SDL_tan().

Referenced by SDL_memset4().

401 {
402 #if defined(HAVE_TANF)
403  return tanf(x);
404 #else
405  return (float)SDL_tan((double)x);
406 #endif
407 }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
double SDL_tan(double x)
Definition: SDL_stdlib.c:390

◆ SDL_tolower()

int SDL_tolower ( int  x)

Definition at line 427 of file SDL_stdlib.c.

References i, L1, L2, L3, L4, L5, L6, memcpy, and pop.

Referenced by SDL_abs().

427 { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_toupper()

int SDL_toupper ( int  x)

Definition at line 426 of file SDL_stdlib.c.

Referenced by SDL_abs().

426 { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574

◆ SDL_uitoa()

char* SDL_uitoa ( unsigned int  value,
char *  str,
int  radix 
)

Definition at line 696 of file SDL_string.c.

References SDL_ultoa().

Referenced by SDL_memset4().

697 {
698 #ifdef HAVE__UITOA
699  return _uitoa(value, string, radix);
700 #else
701  return SDL_ultoa((unsigned long)value, string, radix);
702 #endif /* HAVE__UITOA */
703 }
GLsizei const GLfloat * value
char * SDL_ultoa(unsigned long value, char *string, int radix)
Definition: SDL_string.c:725

◆ SDL_ulltoa()

char* SDL_ulltoa ( Uint64  value,
char *  str,
int  radix 
)

Definition at line 769 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_lltoa(), SDL_memset4(), and SDL_PrintUnsignedLongLong().

770 {
771 #if defined(HAVE__UI64TOA)
772  return _ui64toa(value, string, radix);
773 #else
774  char *bufp = string;
775 
776  if (value) {
777  while (value > 0) {
778  *bufp++ = ntoa_table[value % radix];
779  value /= radix;
780  }
781  } else {
782  *bufp++ = '0';
783  }
784  *bufp = '\0';
785 
786  /* The numbers went into the string backwards. :) */
787  SDL_strrev(string);
788 
789  return string;
790 #endif /* HAVE__UI64TOA */
791 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:677
char * SDL_strrev(char *string)
Definition: SDL_string.c:573
GLsizei const GLfloat * value

◆ SDL_ultoa()

char* SDL_ultoa ( unsigned long  value,
char *  str,
int  radix 
)

Definition at line 725 of file SDL_string.c.

References SDL_strrev().

Referenced by SDL_ltoa(), SDL_memset4(), SDL_PrintUnsignedLong(), and SDL_uitoa().

726 {
727 #if defined(HAVE__ULTOA)
728  return _ultoa(value, string, radix);
729 #else
730  char *bufp = string;
731 
732  if (value) {
733  while (value > 0) {
734  *bufp++ = ntoa_table[value % radix];
735  value /= radix;
736  }
737  } else {
738  *bufp++ = '0';
739  }
740  *bufp = '\0';
741 
742  /* The numbers went into the string backwards. :) */
743  SDL_strrev(string);
744 
745  return string;
746 #endif /* HAVE__ULTOA */
747 }
GLsizei const GLchar *const * string
static const char ntoa_table[]
Definition: SDL_string.c:677
char * SDL_strrev(char *string)
Definition: SDL_string.c:573
GLsizei const GLfloat * value

◆ SDL_utf8strlcpy()

size_t SDL_utf8strlcpy ( SDL_OUT_Z_CAP(dst_bytes) char *  dst,
const char *  src,
size_t  dst_bytes 
)

Definition at line 497 of file SDL_string.c.

References i, SDL_memcpy(), SDL_min, SDL_strlen(), UTF8_IsLeadByte, UTF8_IsTrailingByte, and UTF8_TrailingBytes().

Referenced by SDL_memset4().

498 {
499  size_t src_bytes = SDL_strlen(src);
500  size_t bytes = SDL_min(src_bytes, dst_bytes - 1);
501  size_t i = 0;
502  char trailing_bytes = 0;
503  if (bytes)
504  {
505  unsigned char c = (unsigned char)src[bytes - 1];
506  if (UTF8_IsLeadByte(c))
507  --bytes;
508  else if (UTF8_IsTrailingByte(c))
509  {
510  for (i = bytes - 1; i != 0; --i)
511  {
512  c = (unsigned char)src[i];
513  trailing_bytes = UTF8_TrailingBytes(c);
514  if (trailing_bytes)
515  {
516  if (bytes - i != trailing_bytes + 1)
517  bytes = i;
518 
519  break;
520  }
521  }
522  }
523  SDL_memcpy(dst, src, bytes);
524  }
525  dst[bytes] = '\0';
526  return bytes;
527 }
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
GLenum GLenum dst
GLenum src
size_t SDL_strlen(const char *string)
Definition: SDL_string.c:406
#define UTF8_IsLeadByte(c)
Definition: SDL_string.c:36
const GLubyte * c
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310
static int UTF8_TrailingBytes(unsigned char c)
Definition: SDL_string.c:39
#define UTF8_IsTrailingByte(c)
Definition: SDL_string.c:37

◆ SDL_utf8strlen()

size_t SDL_utf8strlen ( const char *  str)

Definition at line 530 of file SDL_string.c.

References retval.

Referenced by SDL_memset4().

531 {
532  size_t retval = 0;
533  const char *p = str;
534  char ch;
535 
536  while ((ch = *(p++))) {
537  /* if top two bits are 1 and 0, it's a continuation byte. */
538  if ((ch & 0xc0) != 0x80) {
539  retval++;
540  }
541  }
542 
543  return retval;
544 }
GLfloat GLfloat p
SDL_bool retval

◆ SDL_vsnprintf()

int SDL_vsnprintf ( SDL_OUT_Z_CAP(maxlen) char *  text,
size_t  maxlen,
const char *  fmt,
va_list  ap 
)

Definition at line 1524 of file SDL_string.c.

References done, SDL_FormatInfo::force_case, SDL_FormatInfo::force_sign, SDL_FormatInfo::force_type, SDL_FormatInfo::left_justify, SDL_FormatInfo::pad_zeroes, SDL_FormatInfo::precision, SDL_FormatInfo::radix, SDL_CASE_LOWER, SDL_CASE_NOCHANGE, SDL_CASE_UPPER, SDL_FALSE, SDL_free, SDL_iconv_string, SDL_min, SDL_PrintFloat(), SDL_PrintLong(), SDL_PrintLongLong(), SDL_PrintString(), SDL_PrintUnsignedLong(), SDL_PrintUnsignedLongLong(), SDL_strncmp(), SDL_strtol(), SDL_TRUE, SDL_wcslen(), SDL_zero, text, and SDL_FormatInfo::width.

Referenced by SDL_memset4(), and SDL_snprintf().

1525 {
1526  size_t left = maxlen;
1527  char *textstart = text;
1528 
1529  if (!fmt) {
1530  fmt = "";
1531  }
1532  while (*fmt && left > 1) {
1533  if (*fmt == '%') {
1535  size_t len = 0;
1536  SDL_bool check_flag;
1537  SDL_FormatInfo info;
1538  enum
1539  {
1540  DO_INT,
1541  DO_LONG,
1542  DO_LONGLONG
1543  } inttype = DO_INT;
1544 
1545  SDL_zero(info);
1546  info.radix = 10;
1547  info.precision = -1;
1548 
1549  check_flag = SDL_TRUE;
1550  while (check_flag) {
1551  ++fmt;
1552  switch (*fmt) {
1553  case '-':
1554  info.left_justify = SDL_TRUE;
1555  break;
1556  case '+':
1557  info.force_sign = SDL_TRUE;
1558  break;
1559  case '#':
1560  info.force_type = SDL_TRUE;
1561  break;
1562  case '0':
1563  info.pad_zeroes = SDL_TRUE;
1564  break;
1565  default:
1566  check_flag = SDL_FALSE;
1567  break;
1568  }
1569  }
1570 
1571  if (*fmt >= '0' && *fmt <= '9') {
1572  info.width = SDL_strtol(fmt, (char **)&fmt, 0);
1573  }
1574 
1575  if (*fmt == '.') {
1576  ++fmt;
1577  if (*fmt >= '0' && *fmt <= '9') {
1578  info.precision = SDL_strtol(fmt, (char **)&fmt, 0);
1579  } else {
1580  info.precision = 0;
1581  }
1582  }
1583 
1584  while (!done) {
1585  switch (*fmt) {
1586  case '%':
1587  if (left > 1) {
1588  *text = '%';
1589  }
1590  len = 1;
1591  done = SDL_TRUE;
1592  break;
1593  case 'c':
1594  /* char is promoted to int when passed through (...) */
1595  if (left > 1) {
1596  *text = (char) va_arg(ap, int);
1597  }
1598  len = 1;
1599  done = SDL_TRUE;
1600  break;
1601  case 'h':
1602  /* short is promoted to int when passed through (...) */
1603  break;
1604  case 'l':
1605  if (inttype < DO_LONGLONG) {
1606  ++inttype;
1607  }
1608  break;
1609  case 'I':
1610  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1611  fmt += 2;
1612  inttype = DO_LONGLONG;
1613  }
1614  break;
1615  case 'i':
1616  case 'd':
1617  switch (inttype) {
1618  case DO_INT:
1619  len = SDL_PrintLong(text, left, &info,
1620  (long) va_arg(ap, int));
1621  break;
1622  case DO_LONG:
1623  len = SDL_PrintLong(text, left, &info,
1624  va_arg(ap, long));
1625  break;
1626  case DO_LONGLONG:
1627  len = SDL_PrintLongLong(text, left, &info,
1628  va_arg(ap, Sint64));
1629  break;
1630  }
1631  done = SDL_TRUE;
1632  break;
1633  case 'p':
1634  case 'x':
1635  info.force_case = SDL_CASE_LOWER;
1636  /* Fall through to 'X' handling */
1637  case 'X':
1638  if (info.force_case == SDL_CASE_NOCHANGE) {
1639  info.force_case = SDL_CASE_UPPER;
1640  }
1641  if (info.radix == 10) {
1642  info.radix = 16;
1643  }
1644  if (*fmt == 'p') {
1645  inttype = DO_LONG;
1646  }
1647  /* Fall through to unsigned handling */
1648  case 'o':
1649  if (info.radix == 10) {
1650  info.radix = 8;
1651  }
1652  /* Fall through to unsigned handling */
1653  case 'u':
1654  info.pad_zeroes = SDL_TRUE;
1655  switch (inttype) {
1656  case DO_INT:
1657  len = SDL_PrintUnsignedLong(text, left, &info,
1658  (unsigned long)
1659  va_arg(ap, unsigned int));
1660  break;
1661  case DO_LONG:
1662  len = SDL_PrintUnsignedLong(text, left, &info,
1663  va_arg(ap, unsigned long));
1664  break;
1665  case DO_LONGLONG:
1666  len = SDL_PrintUnsignedLongLong(text, left, &info,
1667  va_arg(ap, Uint64));
1668  break;
1669  }
1670  done = SDL_TRUE;
1671  break;
1672  case 'f':
1673  len = SDL_PrintFloat(text, left, &info, va_arg(ap, double));
1674  done = SDL_TRUE;
1675  break;
1676  case 'S':
1677  {
1678  /* In practice this is used on Windows for WCHAR strings */
1679  wchar_t *wide_arg = va_arg(ap, wchar_t *);
1680  char *arg = SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(wide_arg), (SDL_wcslen(wide_arg)+1)*sizeof(*wide_arg));
1681  len = SDL_PrintString(text, left, &info, arg);
1682  SDL_free(arg);
1683  done = SDL_TRUE;
1684  }
1685  break;
1686  case 's':
1687  len = SDL_PrintString(text, left, &info, va_arg(ap, char *));
1688  done = SDL_TRUE;
1689  break;
1690  default:
1691  done = SDL_TRUE;
1692  break;
1693  }
1694  ++fmt;
1695  }
1696  if (len >= left) {
1697  text += (left > 1) ? left - 1 : 0;
1698  left = SDL_min(left, 1);
1699  } else {
1700  text += len;
1701  left -= len;
1702  }
1703  } else {
1704  *text++ = *fmt++;
1705  --left;
1706  }
1707  }
1708  if (left > 0) {
1709  *text = '\0';
1710  }
1711  return (int)(text - textstart);
1712 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
SDL_bool left_justify
Definition: SDL_string.c:1341
SDL_bool pad_zeroes
Definition: SDL_string.c:1344
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
SDL_bool force_type
Definition: SDL_string.c:1343
uint64_t Uint64
Definition: SDL_stdinc.h:194
GLenum GLsizei len
long SDL_strtol(const char *string, char **endp, int base)
Definition: SDL_string.c:812
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
Definition: SDL_string.c:1403
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
Definition: SDL_string.c:1385
SDL_bool force_sign
Definition: SDL_string.c:1342
#define SDL_free
int done
Definition: checkkeys.c:28
#define SDL_zero(x)
Definition: SDL_stdinc.h:416
SDL_bool
Definition: SDL_stdinc.h:139
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
#define SDL_iconv_string
SDL_letter_case force_case
Definition: SDL_string.c:1345
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
Definition: SDL_string.c:1412
int64_t Sint64
Definition: SDL_stdinc.h:188
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
Definition: SDL_string.c:1352
GLint left
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
Definition: SDL_string.c:1394
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
Definition: SDL_string.c:1421

◆ SDL_vsscanf()

int SDL_vsscanf ( const char *  text,
const char *  fmt,
va_list  ap 
)

Definition at line 1036 of file SDL_string.c.

References done, retval, SDL_FALSE, SDL_isspace, SDL_ScanFloat(), SDL_ScanLong(), SDL_ScanLongLong(), SDL_ScanUintPtrT(), SDL_ScanUnsignedLong(), SDL_ScanUnsignedLongLong(), SDL_strncmp(), SDL_tolower, SDL_TRUE, and text.

Referenced by SDL_memset4(), and SDL_sscanf().

1037 {
1038  int retval = 0;
1039 
1040  if (!text || !*text) {
1041  return -1;
1042  }
1043 
1044  while (*fmt) {
1045  if (*fmt == ' ') {
1046  while (SDL_isspace((unsigned char) *text)) {
1047  ++text;
1048  }
1049  ++fmt;
1050  continue;
1051  }
1052  if (*fmt == '%') {
1054  long count = 0;
1055  int radix = 10;
1056  enum
1057  {
1058  DO_SHORT,
1059  DO_INT,
1060  DO_LONG,
1061  DO_LONGLONG
1062  } inttype = DO_INT;
1063  size_t advance;
1064  SDL_bool suppress = SDL_FALSE;
1065 
1066  ++fmt;
1067  if (*fmt == '%') {
1068  if (*text == '%') {
1069  ++text;
1070  ++fmt;
1071  continue;
1072  }
1073  break;
1074  }
1075  if (*fmt == '*') {
1076  suppress = SDL_TRUE;
1077  ++fmt;
1078  }
1079  fmt += SDL_ScanLong(fmt, 10, &count);
1080 
1081  if (*fmt == 'c') {
1082  if (!count) {
1083  count = 1;
1084  }
1085  if (suppress) {
1086  while (count--) {
1087  ++text;
1088  }
1089  } else {
1090  char *valuep = va_arg(ap, char *);
1091  while (count--) {
1092  *valuep++ = *text++;
1093  }
1094  ++retval;
1095  }
1096  continue;
1097  }
1098 
1099  while (SDL_isspace((unsigned char) *text)) {
1100  ++text;
1101  }
1102 
1103  /* FIXME: implement more of the format specifiers */
1104  while (!done) {
1105  switch (*fmt) {
1106  case '*':
1107  suppress = SDL_TRUE;
1108  break;
1109  case 'h':
1110  if (inttype > DO_SHORT) {
1111  ++inttype;
1112  }
1113  break;
1114  case 'l':
1115  if (inttype < DO_LONGLONG) {
1116  ++inttype;
1117  }
1118  break;
1119  case 'I':
1120  if (SDL_strncmp(fmt, "I64", 3) == 0) {
1121  fmt += 2;
1122  inttype = DO_LONGLONG;
1123  }
1124  break;
1125  case 'i':
1126  {
1127  int index = 0;
1128  if (text[index] == '-') {
1129  ++index;
1130  }
1131  if (text[index] == '0') {
1132  if (SDL_tolower((unsigned char) text[index + 1]) == 'x') {
1133  radix = 16;
1134  } else {
1135  radix = 8;
1136  }
1137  }
1138  }
1139  /* Fall through to %d handling */
1140  case 'd':
1141  if (inttype == DO_LONGLONG) {
1142  Sint64 value;
1143  advance = SDL_ScanLongLong(text, radix, &value);
1144  text += advance;
1145  if (advance && !suppress) {
1146  Sint64 *valuep = va_arg(ap, Sint64 *);
1147  *valuep = value;
1148  ++retval;
1149  }
1150  } else {
1151  long value;
1152  advance = SDL_ScanLong(text, radix, &value);
1153  text += advance;
1154  if (advance && !suppress) {
1155  switch (inttype) {
1156  case DO_SHORT:
1157  {
1158  short *valuep = va_arg(ap, short *);
1159  *valuep = (short) value;
1160  }
1161  break;
1162  case DO_INT:
1163  {
1164  int *valuep = va_arg(ap, int *);
1165  *valuep = (int) value;
1166  }
1167  break;
1168  case DO_LONG:
1169  {
1170  long *valuep = va_arg(ap, long *);
1171  *valuep = value;
1172  }
1173  break;
1174  case DO_LONGLONG:
1175  /* Handled above */
1176  break;
1177  }
1178  ++retval;
1179  }
1180  }
1181  done = SDL_TRUE;
1182  break;
1183  case 'o':
1184  if (radix == 10) {
1185  radix = 8;
1186  }
1187  /* Fall through to unsigned handling */
1188  case 'x':
1189  case 'X':
1190  if (radix == 10) {
1191  radix = 16;
1192  }
1193  /* Fall through to unsigned handling */
1194  case 'u':
1195  if (inttype == DO_LONGLONG) {
1196  Uint64 value = 0;
1197  advance = SDL_ScanUnsignedLongLong(text, radix, &value);
1198  text += advance;
1199  if (advance && !suppress) {
1200  Uint64 *valuep = va_arg(ap, Uint64 *);
1201  *valuep = value;
1202  ++retval;
1203  }
1204  } else {
1205  unsigned long value = 0;
1206  advance = SDL_ScanUnsignedLong(text, radix, &value);
1207  text += advance;
1208  if (advance && !suppress) {
1209  switch (inttype) {
1210  case DO_SHORT:
1211  {
1212  short *valuep = va_arg(ap, short *);
1213  *valuep = (short) value;
1214  }
1215  break;
1216  case DO_INT:
1217  {
1218  int *valuep = va_arg(ap, int *);
1219  *valuep = (int) value;
1220  }
1221  break;
1222  case DO_LONG:
1223  {
1224  long *valuep = va_arg(ap, long *);
1225  *valuep = value;
1226  }
1227  break;
1228  case DO_LONGLONG:
1229  /* Handled above */
1230  break;
1231  }
1232  ++retval;
1233  }
1234  }
1235  done = SDL_TRUE;
1236  break;
1237  case 'p':
1238  {
1239  uintptr_t value = 0;
1240  advance = SDL_ScanUintPtrT(text, 16, &value);
1241  text += advance;
1242  if (advance && !suppress) {
1243  void **valuep = va_arg(ap, void **);
1244  *valuep = (void *) value;
1245  ++retval;
1246  }
1247  }
1248  done = SDL_TRUE;
1249  break;
1250  case 'f':
1251  {
1252  double value;
1253  advance = SDL_ScanFloat(text, &value);
1254  text += advance;
1255  if (advance && !suppress) {
1256  float *valuep = va_arg(ap, float *);
1257  *valuep = (float) value;
1258  ++retval;
1259  }
1260  }
1261  done = SDL_TRUE;
1262  break;
1263  case 's':
1264  if (suppress) {
1265  while (!SDL_isspace((unsigned char) *text)) {
1266  ++text;
1267  if (count) {
1268  if (--count == 0) {
1269  break;
1270  }
1271  }
1272  }
1273  } else {
1274  char *valuep = va_arg(ap, char *);
1275  while (!SDL_isspace((unsigned char) *text)) {
1276  *valuep++ = *text++;
1277  if (count) {
1278  if (--count == 0) {
1279  break;
1280  }
1281  }
1282  }
1283  *valuep = '\0';
1284  ++retval;
1285  }
1286  done = SDL_TRUE;
1287  break;
1288  default:
1289  done = SDL_TRUE;
1290  break;
1291  }
1292  ++fmt;
1293  }
1294  continue;
1295  }
1296  if (*text == *fmt) {
1297  ++text;
1298  ++fmt;
1299  continue;
1300  }
1301  /* Text didn't match format specifier */
1302  break;
1303  }
1304 
1305  return retval;
1306 }
static size_t SDL_ScanFloat(const char *text, double *valuep)
Definition: SDL_string.c:231
int SDL_strncmp(const char *str1, const char *str2, size_t maxlen)
Definition: SDL_string.c:945
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
#define SDL_tolower
uint64_t Uint64
Definition: SDL_stdinc.h:194
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
Definition: SDL_string.c:126
static size_t SDL_ScanLong(const char *text, int radix, long *valuep)
Definition: SDL_string.c:53
SDL_bool retval
int done
Definition: checkkeys.c:28
GLsizei const GLfloat * value
unsigned int uintptr_t
#define SDL_isspace
GLuint index
SDL_bool
Definition: SDL_stdinc.h:139
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 *valuep)
Definition: SDL_string.c:158
int64_t Sint64
Definition: SDL_stdinc.h:188
static size_t SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 *valuep)
Definition: SDL_string.c:199
static size_t SDL_ScanUnsignedLong(const char *text, int radix, unsigned long *valuep)
Definition: SDL_string.c:94

◆ SDL_wcscmp()

int SDL_wcscmp ( const wchar_t *  str1,
const wchar_t *  str2 
)

Definition at line 465 of file SDL_string.c.

Referenced by SDL_memset4().

466 {
467 #if defined(HAVE_WCSCMP)
468  return wcscmp(str1, str2);
469 #else
470  while (*str1 && *str2) {
471  if (*str1 != *str2)
472  break;
473  ++str1;
474  ++str2;
475  }
476  return (int)(*str1 - *str2);
477 #endif /* HAVE_WCSCMP */
478 }

◆ SDL_wcslcat()

size_t SDL_wcslcat ( SDL_INOUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 450 of file SDL_string.c.

References SDL_wcslcpy(), and SDL_wcslen().

Referenced by SDL_memset4().

451 {
452 #if defined(HAVE_WCSLCAT)
453  return wcslcat(dst, src, maxlen);
454 #else
455  size_t dstlen = SDL_wcslen(dst);
456  size_t srclen = SDL_wcslen(src);
457  if (dstlen < maxlen) {
458  SDL_wcslcpy(dst + dstlen, src, maxlen - dstlen);
459  }
460  return dstlen + srclen;
461 #endif /* HAVE_WCSLCAT */
462 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
GLenum GLenum dst
GLenum src
size_t SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen)
Definition: SDL_string.c:434

◆ SDL_wcslcpy()

size_t SDL_wcslcpy ( SDL_OUT_Z_CAP(maxlen) wchar_t *  dst,
const wchar_t *  src,
size_t  maxlen 
)

Definition at line 434 of file SDL_string.c.

References SDL_memcpy(), SDL_min, and SDL_wcslen().

Referenced by SDL_memset4(), and SDL_wcslcat().

435 {
436 #if defined(HAVE_WCSLCPY)
437  return wcslcpy(dst, src, maxlen);
438 #else
439  size_t srclen = SDL_wcslen(src);
440  if (maxlen > 0) {
441  size_t len = SDL_min(srclen, maxlen - 1);
442  SDL_memcpy(dst, src, len * sizeof(wchar_t));
443  dst[len] = '\0';
444  }
445  return srclen;
446 #endif /* HAVE_WCSLCPY */
447 }
size_t SDL_wcslen(const wchar_t *string)
Definition: SDL_string.c:420
#define SDL_min(x, y)
Definition: SDL_stdinc.h:406
GLenum GLenum dst
GLenum src
GLenum GLsizei len
void * SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
Definition: SDL_string.c:310

◆ SDL_wcslen()

size_t SDL_wcslen ( const wchar_t *  wstr)

Definition at line 420 of file SDL_string.c.

Referenced by SDL_memset4(), SDL_vsnprintf(), SDL_wcslcat(), and SDL_wcslcpy().

421 {
422 #if defined(HAVE_WCSLEN)
423  return wcslen(string);
424 #else
425  size_t len = 0;
426  while (*string++) {
427  ++len;
428  }
429  return len;
430 #endif /* HAVE_WCSLEN */
431 }
GLenum GLsizei len