Updated source to match SDL function prototype style

This commit is contained in:
Sam Lantinga
2023-05-23 10:59:03 -07:00
parent 92f72682e7
commit 3f1fd5abff
243 changed files with 1218 additions and 2364 deletions

View File

@@ -168,8 +168,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
/* Retrieve a variable named "name" from the environment */
#if defined(HAVE_GETENV)
char *
SDL_getenv(const char *name)
char *SDL_getenv(const char *name)
{
#if defined(__ANDROID__)
/* Make sure variables from the application manifest are available */
@@ -184,8 +183,7 @@ SDL_getenv(const char *name)
return getenv(name);
}
#elif defined(__WIN32__) || defined(__WINGDK__)
char *
SDL_getenv(const char *name)
char *SDL_getenv(const char *name)
{
size_t bufferlen;
@@ -211,8 +209,7 @@ SDL_getenv(const char *name)
return SDL_envmem;
}
#else
char *
SDL_getenv(const char *name)
char *SDL_getenv(const char *name)
{
size_t len, i;
char *value;

View File

@@ -40,8 +40,7 @@
SDL_COMPILE_TIME_ASSERT(iconv_t, sizeof(iconv_t) <= sizeof(SDL_iconv_t));
SDL_iconv_t
SDL_iconv_open(const char *tocode, const char *fromcode)
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
{
return (SDL_iconv_t)((uintptr_t)iconv_open(tocode, fromcode));
}
@@ -51,8 +50,7 @@ int SDL_iconv_close(SDL_iconv_t cd)
return iconv_close((iconv_t)((uintptr_t)cd));
}
size_t
SDL_iconv(SDL_iconv_t cd,
size_t SDL_iconv(SDL_iconv_t cd,
const char **inbuf, size_t *inbytesleft,
char **outbuf, size_t *outbytesleft)
{
@@ -196,8 +194,7 @@ static const char *getlocale(char *buffer, size_t bufsize)
return buffer;
}
SDL_iconv_t
SDL_iconv_open(const char *tocode, const char *fromcode)
SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
{
int src_fmt = ENCODING_UNKNOWN;
int dst_fmt = ENCODING_UNKNOWN;
@@ -789,9 +786,7 @@ int SDL_iconv_close(SDL_iconv_t cd)
#endif /* !HAVE_ICONV */
char *
SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf,
size_t inbytesleft)
char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft)
{
SDL_iconv_t cd;
char *string;

View File

@@ -28,8 +28,7 @@
#include "SDL_stdinc.h"
#if defined(HAVE_QSORT)
void
SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *))
{
qsort(base, nmemb, size, compare);
}
@@ -534,8 +533,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size,
#endif /* HAVE_QSORT */
void *
SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *))
{
#if defined(HAVE_BSEARCH)
return bsearch(key, base, nmemb, size, compare);

View File

@@ -518,8 +518,7 @@ int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a' + ((x) - 'A'
/* This file contains a portable memcpy manipulation function for SDL */
void *
SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
void *SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
{
#ifdef __GNUC__
/* Presumably this is well tuned for speed.
@@ -571,8 +570,7 @@ SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src,
#endif /* __GNUC__ */
}
void *
SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
void *SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len)
{
#if defined(HAVE_MEMSET)
return memset(dst, c, len);

View File

@@ -55,8 +55,7 @@ static unsigned UTF8_TrailingBytes(unsigned char c)
}
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOL) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
static size_t
SDL_ScanLong(const char *text, int count, int radix, long *valuep)
static size_t SDL_ScanLong(const char *text, int count, int radix, long *valuep)
{
const char *textstart = text;
long value = 0;
@@ -100,8 +99,7 @@ SDL_ScanLong(const char *text, int count, int radix, long *valuep)
#endif
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOUL) || !defined(HAVE_STRTOD)
static size_t
SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valuep)
static size_t SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valuep)
{
const char *textstart = text;
unsigned long value = 0;
@@ -140,8 +138,7 @@ SDL_ScanUnsignedLong(const char *text, int count, int radix, unsigned long *valu
#endif
#ifndef HAVE_VSSCANF
static size_t
SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
static size_t SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
{
const char *textstart = text;
uintptr_t value = 0;
@@ -172,8 +169,7 @@ SDL_ScanUintPtrT(const char *text, int radix, uintptr_t *valuep)
#endif
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOLL) || !defined(HAVE_STRTOULL)
static size_t
SDL_ScanLongLong(const char *text, int count, int radix, Sint64 *valuep)
static size_t SDL_ScanLongLong(const char *text, int count, int radix, Sint64 *valuep)
{
const char *textstart = text;
Sint64 value = 0;
@@ -217,8 +213,7 @@ SDL_ScanLongLong(const char *text, int count, int radix, Sint64 *valuep)
#endif
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOULL)
static size_t
SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 *valuep)
static size_t SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 *valuep)
{
const char *textstart = text;
Uint64 value = 0;
@@ -257,8 +252,7 @@ SDL_ScanUnsignedLongLong(const char *text, int count, int radix, Uint64 *valuep)
#endif
#if !defined(HAVE_VSSCANF) || !defined(HAVE_STRTOD)
static size_t
SDL_ScanFloat(const char *text, double *valuep)
static size_t SDL_ScanFloat(const char *text, double *valuep)
{
const char *textstart = text;
unsigned long lvalue = 0;
@@ -292,8 +286,7 @@ SDL_ScanFloat(const char *text, double *valuep)
}
#endif
void *
SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
void *SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len)
{
#if defined(HAVE_MEMMOVE)
return memmove(dst, src, len);
@@ -404,8 +397,7 @@ SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t max
#endif /* HAVE_WCSLCAT */
}
wchar_t *
SDL_wcsdup(const wchar_t *string)
wchar_t *SDL_wcsdup(const wchar_t *string)
{
size_t len = ((SDL_wcslen(string) + 1) * sizeof(wchar_t));
wchar_t *newstr = (wchar_t *)SDL_malloc(len);
@@ -415,8 +407,7 @@ SDL_wcsdup(const wchar_t *string)
return newstr;
}
wchar_t *
SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
wchar_t *SDL_wcsstr(const wchar_t *haystack, const wchar_t *needle)
{
#if defined(HAVE_WCSSTR)
return SDL_const_cast(wchar_t *, wcsstr(haystack, needle));
@@ -645,8 +636,7 @@ SDL_strlcat(SDL_INOUT_Z_CAP(maxlen) char *dst, const char *src, size_t maxlen)
#endif /* HAVE_STRLCAT */
}
char *
SDL_strdup(const char *string)
char *SDL_strdup(const char *string)
{
size_t len = SDL_strlen(string) + 1;
char *newstr = (char *)SDL_malloc(len);
@@ -656,8 +646,7 @@ SDL_strdup(const char *string)
return newstr;
}
char *
SDL_strrev(char *string)
char *SDL_strrev(char *string)
{
#if defined(HAVE__STRREV)
return _strrev(string);
@@ -675,8 +664,7 @@ SDL_strrev(char *string)
#endif /* HAVE__STRREV */
}
char *
SDL_strupr(char *string)
char *SDL_strupr(char *string)
{
#if defined(HAVE__STRUPR)
return _strupr(string);
@@ -690,8 +678,7 @@ SDL_strupr(char *string)
#endif /* HAVE__STRUPR */
}
char *
SDL_strlwr(char *string)
char *SDL_strlwr(char *string)
{
#if defined(HAVE__STRLWR)
return _strlwr(string);
@@ -705,8 +692,7 @@ SDL_strlwr(char *string)
#endif /* HAVE__STRLWR */
}
char *
SDL_strchr(const char *string, int c)
char *SDL_strchr(const char *string, int c)
{
#ifdef HAVE_STRCHR
return SDL_const_cast(char *, strchr(string, c));
@@ -726,8 +712,7 @@ SDL_strchr(const char *string, int c)
#endif /* HAVE_STRCHR */
}
char *
SDL_strrchr(const char *string, int c)
char *SDL_strrchr(const char *string, int c)
{
#ifdef HAVE_STRRCHR
return SDL_const_cast(char *, strrchr(string, c));
@@ -745,8 +730,7 @@ SDL_strrchr(const char *string, int c)
#endif /* HAVE_STRRCHR */
}
char *
SDL_strstr(const char *haystack, const char *needle)
char *SDL_strstr(const char *haystack, const char *needle)
{
#if defined(HAVE_STRSTR)
return SDL_const_cast(char *, strstr(haystack, needle));
@@ -762,8 +746,7 @@ SDL_strstr(const char *haystack, const char *needle)
#endif /* HAVE_STRSTR */
}
char *
SDL_strcasestr(const char *haystack, const char *needle)
char *SDL_strcasestr(const char *haystack, const char *needle)
{
#if defined(HAVE_STRCASESTR)
return SDL_const_cast(char *, strcasestr(haystack, needle));
@@ -789,8 +772,7 @@ static const char ntoa_table[] = {
};
#endif /* ntoa() conversion table */
char *
SDL_itoa(int value, char *string, int radix)
char *SDL_itoa(int value, char *string, int radix)
{
#ifdef HAVE_ITOA
return itoa(value, string, radix);
@@ -799,8 +781,7 @@ SDL_itoa(int value, char *string, int radix)
#endif /* HAVE_ITOA */
}
char *
SDL_uitoa(unsigned int value, char *string, int radix)
char *SDL_uitoa(unsigned int value, char *string, int radix)
{
#ifdef HAVE__UITOA
return _uitoa(value, string, radix);
@@ -809,8 +790,7 @@ SDL_uitoa(unsigned int value, char *string, int radix)
#endif /* HAVE__UITOA */
}
char *
SDL_ltoa(long value, char *string, int radix)
char *SDL_ltoa(long value, char *string, int radix)
{
#if defined(HAVE__LTOA)
return _ltoa(value, string, radix);
@@ -828,8 +808,7 @@ SDL_ltoa(long value, char *string, int radix)
#endif /* HAVE__LTOA */
}
char *
SDL_ultoa(unsigned long value, char *string, int radix)
char *SDL_ultoa(unsigned long value, char *string, int radix)
{
#if defined(HAVE__ULTOA)
return _ultoa(value, string, radix);
@@ -853,8 +832,7 @@ SDL_ultoa(unsigned long value, char *string, int radix)
#endif /* HAVE__ULTOA */
}
char *
SDL_lltoa(Sint64 value, char *string, int radix)
char *SDL_lltoa(Sint64 value, char *string, int radix)
{
#if defined(HAVE__I64TOA)
return _i64toa(value, string, radix);
@@ -872,8 +850,7 @@ SDL_lltoa(Sint64 value, char *string, int radix)
#endif /* HAVE__I64TOA */
}
char *
SDL_ulltoa(Uint64 value, char *string, int radix)
char *SDL_ulltoa(Uint64 value, char *string, int radix)
{
#if defined(HAVE__UI64TOA)
return _ui64toa(value, string, radix);
@@ -964,8 +941,7 @@ SDL_strtoul(const char *string, char **endp, int base)
#endif /* HAVE_STRTOUL */
}
Sint64
SDL_strtoll(const char *string, char **endp, int base)
Sint64 SDL_strtoll(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOLL)
return strtoll(string, endp, base);
@@ -989,8 +965,7 @@ SDL_strtoll(const char *string, char **endp, int base)
#endif /* HAVE_STRTOLL */
}
Uint64
SDL_strtoull(const char *string, char **endp, int base)
Uint64 SDL_strtoull(const char *string, char **endp, int base)
{
#if defined(HAVE_STRTOULL)
return strtoull(string, endp, base);
@@ -1491,8 +1466,7 @@ typedef struct
int precision;
} SDL_FormatInfo;
static size_t
SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, const char *string)
{
size_t length = 0;
size_t slen, sz;
@@ -1577,8 +1551,7 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf
}
}
static size_t
SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
static size_t SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
{
char num[130], *p = num;
@@ -1591,8 +1564,7 @@ SDL_PrintLong(char *text, size_t maxlen, SDL_FormatInfo *info, long value)
return SDL_PrintString(text, maxlen, info, num);
}
static size_t
SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
static size_t SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned long value)
{
char num[130];
@@ -1601,8 +1573,7 @@ SDL_PrintUnsignedLong(char *text, size_t maxlen, SDL_FormatInfo *info, unsigned
return SDL_PrintString(text, maxlen, info, num);
}
static size_t
SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
static size_t SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
{
char num[130], *p = num;
@@ -1615,8 +1586,7 @@ SDL_PrintLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Sint64 value)
return SDL_PrintString(text, maxlen, info, num);
}
static size_t
SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
static size_t SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint64 value)
{
char num[130];
@@ -1625,8 +1595,7 @@ SDL_PrintUnsignedLongLong(char *text, size_t maxlen, SDL_FormatInfo *info, Uint6
return SDL_PrintString(text, maxlen, info, num);
}
static size_t
SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, double arg)
{
size_t length = 0;