From d31251b0142ae6b275c75a13ce79288b9eb4864d Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Sun, 21 Nov 2021 22:30:48 +0100
Subject: [PATCH] use SDL's functions version inplace of libc version
---
Xcode-iOS/Demos/src/accelerometer.c | 2 +-
Xcode-iOS/Demos/src/fireworks.c | 12 ++---
Xcode-iOS/Demos/src/touch.c | 2 +-
src/audio/SDL_audio.c | 2 +-
src/audio/alsa/SDL_alsa_audio.c | 2 +-
src/audio/psp/SDL_pspaudio.c | 2 +-
src/audio/vita/SDL_vitaaudio.c | 2 +-
src/core/freebsd/SDL_evdev_kbd_freebsd.c | 2 +-
src/core/openbsd/SDL_wscons_kbd.c | 4 +-
src/cpuinfo/SDL_cpuinfo.c | 4 +-
src/filesystem/unix/SDL_sysfilesystem.c | 2 +-
src/haptic/linux/SDL_syshaptic.c | 5 +-
src/hidapi/android/hid.cpp | 23 ++++-----
src/joystick/hidapi/SDL_hidapi_steam.c | 50 +++++++++----------
src/locale/SDL_locale.c | 2 +-
src/misc/vita/SDL_sysurl.c | 2 +-
src/power/haiku/SDL_syspower.c | 2 +-
src/power/linux/SDL_syspower.c | 2 +-
src/render/software/SDL_rotate.c | 4 +-
.../vitagxm/SDL_render_vita_gxm_tools.c | 4 +-
src/video/directfb/SDL_DirectFB_events.c | 2 +-
src/video/directfb/SDL_DirectFB_mouse.c | 2 +-
src/video/directfb/SDL_DirectFB_video.c | 2 +-
src/video/directfb/SDL_DirectFB_window.c | 2 +-
.../emscripten/SDL_emscriptenframebuffer.c | 2 +-
src/video/haiku/SDL_BWin.h | 2 +-
src/video/vita/SDL_vitaframebuffer.c | 2 +-
src/video/vita/SDL_vitatouch.c | 2 +-
src/video/wayland/SDL_waylandvideo.c | 2 +-
src/video/x11/SDL_x11events.c | 14 +++---
src/video/x11/SDL_x11modes.c | 2 +-
src/video/x11/SDL_x11shape.c | 2 +-
src/video/x11/SDL_x11window.c | 4 +-
src/video/x11/edid-parse.c | 2 +-
test/checkkeysthreads.c | 2 +-
test/testautomation_sdltest.c | 6 +--
test/testevdev.c | 10 ++--
test/testgl2.c | 4 +-
test/testgles2_sdf.c | 4 +-
test/testhaptic.c | 16 +++---
test/testime.c | 4 +-
test/testloadso.c | 2 +-
test/testrumble.c | 8 +--
test/testsem.c | 2 +-
test/testtimer.c | 2 +-
test/testyuv_cvt.c | 6 +--
46 files changed, 114 insertions(+), 124 deletions(-)
diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c
index 2cc0123c293..925aee4e3b4 100644
--- a/Xcode-iOS/Demos/src/accelerometer.c
+++ b/Xcode-iOS/Demos/src/accelerometer.c
@@ -58,7 +58,7 @@ render(SDL_Renderer *renderer, int w, int h, double deltaTime)
ay * SDL_IPHONE_MAX_GFORCE / SINT16_MAX * GRAVITY_CONSTANT *
deltaMilliseconds;
- speed = sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
+ speed = SDL_sqrt(shipData.vx * shipData.vx + shipData.vy * shipData.vy);
if (speed > 0) {
/* compensate for friction */
diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c
index 2c4f621f15b..600d20bbb47 100644
--- a/Xcode-iOS/Demos/src/fireworks.c
+++ b/Xcode-iOS/Demos/src/fireworks.c
@@ -109,7 +109,7 @@ stepParticles(double deltaTime)
}
} else {
float speed =
- sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel);
+ SDL_sqrt(curr->xvel * curr->xvel + curr->yvel * curr->yvel);
/* if wind resistance is not powerful enough to stop us completely,
then apply winde resistance, otherwise just stop us completely */
if (WIND_RESISTANCE * deltaMilliseconds < speed) {
@@ -194,15 +194,15 @@ explodeEmitter(struct particle *emitter)
/* come up with a random angle and speed for new particle */
float theta = randomFloat(0, 2.0f * 3.141592);
float exponent = 3.0f;
- float speed = randomFloat(0.00, powf(0.17, exponent));
- speed = powf(speed, 1.0f / exponent);
+ float speed = randomFloat(0.00, SDL_powf(0.17, exponent));
+ speed = SDL_powf(speed, 1.0f / exponent);
/* select the particle at the end of our array */
struct particle *p = &particles[num_active_particles];
/* set the particles properties */
- p->xvel = speed * cos(theta);
- p->yvel = speed * sin(theta);
+ p->xvel = speed * SDL_cos(theta);
+ p->yvel = speed * SDL_sin(theta);
p->x = emitter->x + emitter->xvel;
p->y = emitter->y + emitter->yvel;
p->isActive = 1;
@@ -297,7 +297,7 @@ spawnEmitterParticle(GLfloat x, GLfloat y)
p->y = screen_h;
/* set velocity so that terminal point is (x,y) */
p->xvel = 0;
- p->yvel = -sqrt(2 * ACCEL * (screen_h - y));
+ p->yvel = -SDL_sqrt(2 * ACCEL * (screen_h - y));
/* set other attributes */
p->size = 10 * pointSizeScale;
p->type = emitter;
diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c
index 6f727e43547..918240b8200 100644
--- a/Xcode-iOS/Demos/src/touch.c
+++ b/Xcode-iOS/Demos/src/touch.c
@@ -21,7 +21,7 @@ void
drawLine(SDL_Renderer *renderer, float startx, float starty, float dx, float dy)
{
- float distance = sqrt(dx * dx + dy * dy); /* length of line segment (pythagoras) */
+ float distance = SDL_sqrt(dx * dx + dy * dy); /* length of line segment (pythagoras) */
int iterations = distance / PIXELS_PER_ITERATION + 1; /* number of brush sprites to draw for the line */
float dx_prime = dx / iterations; /* x-shift per iteration */
float dy_prime = dy / iterations; /* y-shift per iteration */
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index fd8e6da8b51..318644e6f96 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -1753,7 +1753,7 @@ SDL_SilenceValueForFormat(const SDL_AudioFormat format)
{
switch (format) {
/* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a
- !!! FIXME: byte for memset() use. This is actually 0.1953 percent
+ !!! FIXME: byte for SDL_memset() use. This is actually 0.1953 percent
!!! FIXME: off from silence. Maybe just don't use U16. */
case AUDIO_U16LSB:
case AUDIO_U16MSB:
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index 79c879fb63a..2c697432496 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -779,7 +779,7 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee
/* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output".
just chop the extra lines off, this seems to get a reasonable device
name without extra details. */
- if ((ptr = strchr(desc, '\n')) != NULL) {
+ if ((ptr = SDL_strchr(desc, '\n')) != NULL) {
*ptr = '\0';
}
diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c
index 5eeb0da5a58..e98604c6c06 100644
--- a/src/audio/psp/SDL_pspaudio.c
+++ b/src/audio/psp/SDL_pspaudio.c
@@ -90,7 +90,7 @@ PSPAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
return SDL_SetError("Couldn't reserve hardware channel");
}
- memset(this->hidden->rawbuf, 0, mixlen);
+ SDL_memset(this->hidden->rawbuf, 0, mixlen);
for (i = 0; i < NUM_BUFFERS; i++) {
this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
}
diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c
index b69aed8d252..72929eb1c3e 100644
--- a/src/audio/vita/SDL_vitaaudio.c
+++ b/src/audio/vita/SDL_vitaaudio.c
@@ -100,7 +100,7 @@ VITAAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
sceAudioOutSetVolume(this->hidden->channel, SCE_AUDIO_VOLUME_FLAG_L_CH|SCE_AUDIO_VOLUME_FLAG_R_CH, vols);
- memset(this->hidden->rawbuf, 0, mixlen);
+ SDL_memset(this->hidden->rawbuf, 0, mixlen);
for (i = 0; i < NUM_BUFFERS; i++) {
this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size];
}
diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c
index 06642b507fc..c74b1b8940b 100644
--- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c
+++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c
@@ -268,7 +268,7 @@ SDL_EVDEV_kbd_init(void)
kbd->key_map = &keymap_default_us_acc;
}
/* Allow inhibiting keyboard mute with env. variable for debugging etc. */
- if (getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) {
+ if (SDL_getenv("SDL_INPUT_FREEBSD_KEEP_KBD") == NULL) {
/* Take keyboard from console and open the actual keyboard device.
* Ensures that the keystrokes do not leak through to the console.
*/
diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c
index a507b6faf18..b59df0fc289 100644
--- a/src/core/openbsd/SDL_wscons_kbd.c
+++ b/src/core/openbsd/SDL_wscons_kbd.c
@@ -509,7 +509,7 @@ static void put_utf8(SDL_WSCONS_input_data* input, uint c)
static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym)
{
if (KS_GROUP(ksym) == KS_GROUP_Keypad) {
- if (isprint(ksym & 0xFF)) ksym &= 0xFF;
+ if (SDL_isprint(ksym & 0xFF)) ksym &= 0xFF;
}
switch(ksym) {
case KS_Escape:
@@ -526,7 +526,7 @@ static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym)
if (input->text_len > 0) {
input->text[input->text_len] = '\0';
SDL_SendKeyboardText(input->text);
- /*memset(input->text, 0, sizeof(input->text));*/
+ /*SDL_memset(input->text, 0, sizeof(input->text));*/
input->text_len = 0;
input->text[0] = 0;
}
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index 77495562f82..a26b8921481 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -377,8 +377,8 @@ CPU_haveARMSIMD(void)
{
const char *plat = (const char *) aux.a_un.a_val;
if (plat) {
- arm_simd = strncmp(plat, "v6l", 3) == 0 ||
- strncmp(plat, "v7l", 3) == 0;
+ arm_simd = SDL_strncmp(plat, "v6l", 3) == 0 ||
+ SDL_strncmp(plat, "v7l", 3) == 0;
}
}
}
diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c
index c39c07a08f0..83321b85b26 100644
--- a/src/filesystem/unix/SDL_sysfilesystem.c
+++ b/src/filesystem/unix/SDL_sysfilesystem.c
@@ -82,7 +82,7 @@ readSymLink(const char *path)
#if defined(__OPENBSD__)
static char *search_path_for_binary(const char *bin)
{
- char *envr = getenv("PATH");
+ char *envr = SDL_getenv("PATH");
size_t alloc_size;
char *exe = NULL;
char *start = envr;
diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c
index 555fd836eca..744a54e6731 100644
--- a/src/haptic/linux/SDL_syshaptic.c
+++ b/src/haptic/linux/SDL_syshaptic.c
@@ -35,7 +35,6 @@
#include <fcntl.h> /* O_RDWR */
#include <limits.h> /* INT_MAX */
#include <errno.h> /* errno, strerror */
-#include <math.h> /* atan2 */
#include <sys/stat.h> /* stat */
/* Just in case. */
@@ -713,10 +712,10 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
else {
float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */
/*
- atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
+ SDL_atan2 takes the parameters: Y-axis-value and X-axis-value (in that order)
- Y-axis-value is the second coordinate (from center to SOUTH)
- X-axis-value is the first coordinate (from center to EAST)
- We add 36000, because atan2 also returns negative values. Then we practically
+ We add 36000, because SDL_atan2 also returns negative values. Then we practically
have the first spherical value. Therefore we proceed as in case
SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value.
--> add 45000 in total
diff --git a/src/hidapi/android/hid.cpp b/src/hidapi/android/hid.cpp
index bac7bc499ae..0984f47eb4f 100644
--- a/src/hidapi/android/hid.cpp
+++ b/src/hidapi/android/hid.cpp
@@ -53,7 +53,6 @@
#include <pthread.h>
#include <errno.h> // For ETIMEDOUT and ECONNRESET
#include <stdlib.h> // For malloc() and free()
-#include <string.h> // For memcpy()
#define TAG "hidapi"
@@ -196,7 +195,7 @@ class hid_buffer
}
m_nSize = nSize;
- memcpy( m_pData, pData, nSize );
+ SDL_memcpy( m_pData, pData, nSize );
}
void clear()
@@ -313,7 +312,7 @@ static jbyteArray NewByteArray( JNIEnv* env, const uint8_t *pData, size_t nDataL
{
jbyteArray array = env->NewByteArray( (jsize)nDataLen );
jbyte *pBuf = env->GetByteArrayElements( array, NULL );
- memcpy( pBuf, pData, nDataLen );
+ SDL_memcpy( pBuf, pData, nDataLen );
env->ReleaseByteArrayElements( array, pBuf, 0 );
return array;
@@ -324,7 +323,7 @@ static char *CreateStringFromJString( JNIEnv *env, const jstring &sString )
size_t nLength = env->GetStringUTFLength( sString );
const char *pjChars = env->GetStringUTFChars( sString, NULL );
char *psString = (char*)malloc( nLength + 1 );
- memcpy( psString, pjChars, nLength );
+ SDL_memcpy( psString, pjChars, nLength );
psString[ nLength ] = '\0';
env->ReleaseStringUTFChars( sString, pjChars );
return psString;
@@ -347,9 +346,9 @@ static wchar_t *CreateWStringFromJString( JNIEnv *env, const jstring &sString )
static wchar_t *CreateWStringFromWString( const wchar_t *pwSrc )
{
- size_t nLength = wcslen( pwSrc );
+ size_t nLength = SDL_wcslen( pwSrc );
wchar_t *pwString = (wchar_t*)malloc( ( nLength + 1 ) * sizeof( wchar_t ) );
- memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) );
+ SDL_memcpy( pwString, pwSrc, nLength * sizeof( wchar_t ) );
pwString[ nLength ] = '\0';
return pwString;
}
@@ -358,7 +357,7 @@ static hid_device_info *CopyHIDDeviceInfo( const hid_device_info *pInfo )
{
hid_device_info *pCopy = new hid_device_info;
*pCopy = *pInfo;
- pCopy->path = strdup( pInfo->path );
+ pCopy->path = SDL_strdup( pInfo->path );
pCopy->product_string = CreateWStringFromWString( pInfo->product_string );
pCopy->manufacturer_string = CreateWStringFromWString( pInfo->manufacturer_string );
pCopy->serial_number = CreateWStringFromWString( pInfo->serial_number );
@@ -579,12 +578,12 @@ class CHIDDevice
if ( m_bIsBLESteamController )
{
data[0] = 0x03;
- memcpy( data + 1, buffer.data(), nDataLen );
+ SDL_memcpy( data + 1, buffer.data(), nDataLen );
++nDataLen;
}
else
{
- memcpy( data, buffer.data(), nDataLen );
+ SDL_memcpy( data, buffer.data(), nDataLen );
}
m_vecData.pop_front();
@@ -721,7 +720,7 @@ class CHIDDevice
}
size_t uBytesToCopy = m_featureReport.size() > nDataLen ? nDataLen : m_featureReport.size();
- memcpy( pData, m_featureReport.data(), uBytesToCopy );
+ SDL_memcpy( pData, m_featureReport.data(), uBytesToCopy );
m_featureReport.clear();
LOGV( "=== Got %u bytes", uBytesToCopy );
@@ -921,7 +920,7 @@ JNIEXPORT void JNICALL HID_DEVICE_MANAGER_JAVA_INTERFACE(HIDDeviceConnected)(JNI
LOGV( "HIDDeviceConnected() id=%d VID/PID = %.4x/%.4x, interface %d\n", nDeviceID, nVendorId, nProductId, nInterface );
hid_device_info *pInfo = new hid_device_info;
- memset( pInfo, 0, sizeof( *pInfo ) );
+ SDL_memset( pInfo, 0, sizeof( *pInfo ) );
pInfo->path = CreateStringFromJString( env, sIdentifier );
pInfo->vendor_id = nVendorId;
pInfo->product_id = nProductId;
@@ -1120,7 +1119,7 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bEx
hid_mutex_guard l( &g_DevicesMutex );
for ( hid_device_ref<CHIDDevice> pCurr = g_Devices; pCurr; pCurr = pCurr->next )
{
- if ( strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 )
+ if ( SDL_strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 )
{
hid_device *pValue = pCurr->GetDevice();
if ( pValue )
diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c
index d89bd083403..5cbf3391bf7 100644
--- a/src/joystick/hidapi/SDL_hidapi_steam.c
+++ b/src/joystick/hidapi/SDL_hidapi_steam.c
@@ -220,7 +220,7 @@ static void hexdump( const uint8_t *ptr, int len )
static void ResetSteamControllerPacketAssembler( SteamControllerPacketAssembler *pAssembler )
{
- memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) );
+ SDL_memset( pAssembler->uBuffer, 0, sizeof( pAssembler->uBuffer ) );
pAssembler->nExpectedSegmentNumber = 0;
}
@@ -279,7 +279,7 @@ static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAs
}
}
- memcpy( pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE,
+ SDL_memcpy( pAssembler->uBuffer + nSegmentNumber * MAX_REPORT_SEGMENT_PAYLOAD_SIZE,
pSegment + 2, // ignore header and report number
MAX_REPORT_SEGMENT_PAYLOAD_SIZE );
@@ -294,7 +294,7 @@ static int WriteSegmentToSteamControllerPacketAssembler( SteamControllerPacketAs
else
{
// Just pass through
- memcpy( pAssembler->uBuffer,
+ SDL_memcpy( pAssembler->uBuffer,
pSegment,
nSegmentLength );
return nSegmentLength;
@@ -331,10 +331,10 @@ static int SetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65], int
nActualDataLen -= nBytesInPacket;
// Construct packet
- memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) );
+ SDL_memset( uPacketBuffer, 0, sizeof( uPacketBuffer ) );
uPacketBuffer[ 0 ] = BLE_REPORT_NUMBER;
uPacketBuffer[ 1 ] = GetSegmentHeader( nSegmentNumber, nActualDataLen == 0 );
- memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket );
+ SDL_memcpy( &uPacketBuffer[ 2 ], pBufferPtr, nBytesInPacket );
pBufferPtr += nBytesInPacket;
nSegmentNumber++;
@@ -364,7 +364,7 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] )
while( nRetries < BLE_MAX_READ_RETRIES )
{
- memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) );
+ SDL_memset( uSegmentBuffer, 0, sizeof( uSegmentBuffer ) );
uSegmentBuffer[ 0 ] = BLE_REPORT_NUMBER;
nRet = SDL_hid_get_feature_report( dev, uSegmentBuffer, sizeof( uSegmentBuffer ) );
DPRINTF( "GetFeatureReport ble ret=%d\n", nRet );
@@ -386,7 +386,7 @@ static int GetFeatureReport( SDL_hid_device *dev, unsigned char uBuffer[65] )
{
// Leave space for "report number"
uBuffer[ 0 ] = 0;
- memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength );
+ SDL_memcpy( uBuffer + 1, assembler.uBuffer, nPacketLength );
return nPacketLength;
}
}
@@ -500,7 +500,7 @@ static bool ResetSteamController( SDL_hid_device *dev, bool bSuppressErrorSpew,
}
// Reset the default settings
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_LOAD_DEFAULT_SETTINGS;
buf[2] = 0;
res = SetFeatureReport( dev, buf, 3 );
@@ -518,7 +518,7 @@ buf[3+nSettings*3+1] = ((uint16_t)VALUE)&0xFF; \
buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
++nSettings;
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES;
ADD_SETTING( SETTING_WIRELESS_PACKET_VERSION, 2 );
ADD_SETTING( SETTING_LEFT_TRACKPAD_MODE, TRACKPAD_NONE );
@@ -547,7 +547,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
int iRetry;
for ( iRetry = 0; iRetry < 2; ++iRetry )
{
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_GET_DIGITAL_MAPPINGS;
buf[2] = 1; // one byte - requesting from index 0
buf[3] = 0;
@@ -580,7 +580,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
}
// Set our new mappings
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_DIGITAL_MAPPINGS;
buf[2] = 6; // 2 settings x 3 bytes
buf[3] = IO_DIGITAL_BUTTON_RIGHT_TRIGGER;
@@ -608,7 +608,7 @@ buf[3+nSettings*3+2] = ((uint16_t)VALUE)>>8; \
//---------------------------------------------------------------------------
static int ReadSteamController( SDL_hid_device *dev, uint8_t *pData, int nDataSize )
{
- memset( pData, 0, nDataSize );
+ SDL_memset( pData, 0, nDataSize );
pData[ 0 ] = BLE_REPORT_NUMBER; // hid_read will also overwrite this with the same value, 0x03
return SDL_hid_read( dev, pData, nDataSize );
}
@@ -624,18 +624,18 @@ static void CloseSteamController( SDL_hid_device *dev )
int nSettings = 0;
// Reset digital button mappings
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_DEFAULT_DIGITAL_MAPPINGS;
SetFeatureReport( dev, buf, 2 );
// Reset the default settings
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_LOAD_DEFAULT_SETTINGS;
buf[2] = 0;
SetFeatureReport( dev, buf, 3 );
// Reset mouse mode for lizard mode
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES;
ADD_SETTING( SETTING_RIGHT_TRACKPAD_MODE, TRACKPAD_ABSOLUTE_MOUSE );
buf[2] = nSettings*3;
@@ -695,14 +695,14 @@ static void FormatStatePacketUntilGyro( SteamControllerStateInternal_t *pState,
// 15 degrees in rad
const float flRotationAngle = 0.261799f;
- memset(pState, 0, offsetof(SteamControllerStateInternal_t, sBatteryLevel));
+ SDL_memset(pState, 0, offsetof(SteamControllerStateInternal_t, sBatteryLevel));
//pState->eControllerType = m_eControllerType;
pState->eControllerType = 2; // k_eControllerType_SteamController;
pState->unPacketNum = pStatePacket->unPacketNum;
// We have a chunk of trigger data in the packet format here, so zero it out afterwards
- memcpy(&pState->ulButtons, &pStatePacket->ButtonTriggerData.ulButtons, 8);
+ SDL_memcpy(&pState->ulButtons, &pStatePacket->ButtonTriggerData.ulButtons, 8);
pState->ulButtons &= ~0xFFFF000000LL;
// The firmware uses this bit to tell us what kind of data is packed into the left two axises
@@ -822,7 +822,7 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
ucOptionDataMask |= (uint32_t)(*pData++) << 8;
if ( ucOptionDataMask & k_EBLEButtonChunk1 )
{
- memcpy( &pState->ulButtons, pData, 3 );
+ SDL_memcpy( &pState->ulButtons, pData, 3 );
pData += 3;
}
if ( ucOptionDataMask & k_EBLEButtonChunk2 )
@@ -844,14 +844,14 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
// This doesn't handle any of the special headcrab stuff for raw joystick which is OK for now since that FW doesn't support
// this protocol yet either
int nLength = sizeof( pState->sLeftStickX ) + sizeof( pState->sLeftStickY );
- memcpy( &pState->sLeftStickX, pData, nLength );
+ SDL_memcpy( &pState->sLeftStickX, pData, nLength );
pData += nLength;
}
if ( ucOptionDataMask & k_EBLELeftTrackpadChunk )
{
int nLength = sizeof( pState->sLeftPadX ) + sizeof( pState->sLeftPadY );
int nPadOffset;
- memcpy( &pState->sLeftPadX, pData, nLength );
+ SDL_memcpy( &pState->sLeftPadX, pData, nLength );
if ( pState->ulButtons & STEAM_LEFTPAD_FINGERDOWN_MASK )
nPadOffset = 1000;
else
@@ -867,7 +867,7 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
int nLength = sizeof( pState->sRightPadX ) + sizeof( pState->sRightPadY );
int nPadOffset = 0;
- memcpy( &pState->sRightPadX, pData, nLength );
+ SDL_memcpy( &pState->sRightPadX, pData, nLength );
if ( pState->ulButtons & STEAM_RIGHTPAD_FINGERDOWN_MASK )
nPadOffset = 1000;
@@ -882,19 +882,19 @@ static bool UpdateBLESteamControllerState( const uint8_t *pData, int nDataSize,
if ( ucOptionDataMask & k_EBLEIMUAccelChunk )
{
int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ );
- memcpy( &pState->sAccelX, pData, nLength );
+ SDL_memcpy( &pState->sAccelX, pData, nLength );
pData += nLength;
}
if ( ucOptionDataMask & k_EBLEIMUGyroChunk )
{
int nLength = sizeof( pState->sAccelX ) + sizeof( pState->sAccelY ) + sizeof( pState->sAccelZ );
- memcpy( &pState->sGyroX, pData, nLength );
+ SDL_memcpy( &pState->sGyroX, pData, nLength );
pData += nLength;
}
if ( ucOptionDataMask & k_EBLEIMUQuatChunk )
{
int nLength = sizeof( pState->sGyroQuatW ) + sizeof( pState->sGyroQuatX ) + sizeof( pState->sGyroQuatY ) + sizeof( pState->sGyroQuatZ );
- memcpy( &pState->sGyroQuatW, pData, nLength );
+ SDL_memcpy( &pState->sGyroQuatW, pData, nLength );
pData += nLength;
}
return true;
@@ -1122,7 +1122,7 @@ HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *jo
unsigned char buf[65];
int nSettings = 0;
- memset( buf, 0, 65 );
+ SDL_memset( buf, 0, 65 );
buf[1] = ID_SET_SETTINGS_VALUES;
if (enabled) {
ADD_SETTING( SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */ );
diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c
index 59f3e7fe573..e475b0755ca 100644
--- a/src/locale/SDL_locale.c
+++ b/src/locale/SDL_locale.c
@@ -45,7 +45,7 @@ build_locales_from_csv_string(char *csv)
num_locales++; /* one more for terminator */
- slen = ((size_t) (ptr - csv)) + 1; /* strlen(csv) + 1 */
+ slen = ((size_t) (ptr - csv)) + 1; /* SDL_strlen(csv) + 1 */
alloclen = slen + (num_locales * sizeof (SDL_Locale));
loc = retval = (SDL_Locale *) SDL_calloc(1, alloclen);
diff --git a/src/misc/vita/SDL_sysurl.c b/src/misc/vita/SDL_sysurl.c
index 42f6c456e08..68f399776bc 100644
--- a/src/misc/vita/SDL_sysurl.c
+++ b/src/misc/vita/SDL_sysurl.c
@@ -35,7 +35,7 @@ SDL_SYS_OpenURL(const char *url)
sceAppUtilInit(&init_param, &boot_param);
SDL_zero(browser_param);
browser_param.str = url;
- browser_param.strlen = strlen(url);
+ browser_param.strlen = SDL_strlen(url);
sceAppUtilLaunchWebBrowser(&browser_param);
return 0;
}
diff --git a/src/power/haiku/SDL_syspower.c b/src/power/haiku/SDL_syspower.c
index 87167b91cb8..4ae9657064e 100644
--- a/src/power/haiku/SDL_syspower.c
+++ b/src/power/haiku/SDL_syspower.c
@@ -59,7 +59,7 @@ SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent)
return SDL_FALSE; /* maybe some other method will work? */
}
- memset(regs, '\0', sizeof(regs));
+ SDL_memset(regs, '\0', sizeof(regs));
regs[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS;
regs[1] = APM_DEVICE_ALL;
rc = ioctl(fd, APM_BIOS_CALL, regs);
diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c
index f911005432b..c02ef0db5ae 100644
--- a/src/power/linux/SDL_syspower.c
+++ b/src/power/linux/SDL_syspower.c
@@ -51,7 +51,7 @@ open_power_file(const char *base, const char *node, const char *key)
return -1; /* oh well. */
}
- snprintf(path, pathlen, "%s/%s/%s", base, node, key);
+ SDL_snprintf(path, pathlen, "%s/%s/%s", base, node, key);
fd = open(path, O_RDONLY | O_CLOEXEC);
SDL_stack_free(path);
return fd;
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index a903d1db2a2..b5ac715e89b 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -184,7 +184,7 @@ computeSourceIncrements90(SDL_Surface * src, int bpp, int angle, int flipx, int
if (signy < 0) sp += (src->h-1)*src->pitch; \
\
for (dy = 0; dy < dst->h; sp += sincy, dp += dincy, dy++) { \
- if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use memcpy */ \
+ if (sincx == sizeof(pixelType)) { /* if advancing src and dest equally, use SDL_memcpy */ \
SDL_memcpy(dp, sp, dst->w*sizeof(pixelType)); \
sp += dst->w*sizeof(pixelType); \
dp += dst->w*sizeof(pixelType); \
@@ -439,7 +439,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
if (!(is8bit || (src->format->BitsPerPixel == 32 && src->format->Amask)))
return NULL;
- /* Calculate target factors from sin/cos and zoom */
+ /* Calculate target factors from sine/cosine and zoom */
sangleinv = sangle*65536.0;
cangleinv = cangle*65536.0;
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index 08c361106b6..6d0a4b9ccc6 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -475,7 +475,7 @@ gxm_init(SDL_Renderer *renderer)
SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
&data->displayBufferUid[i]);
- // memset the buffer to black
+ // SDL_memset the buffer to black
for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) {
unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE;
for (x = 0; x < VITA_GXM_SCREEN_WIDTH; x++) {
@@ -1104,7 +1104,7 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
// set up parameters
SceGxmRenderTargetParams renderTargetParams;
- memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
+ SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams));
renderTargetParams.flags = 0;
renderTargetParams.width = w;
renderTargetParams.height = h;
diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c
index c8c3368a819..7e19bbee790 100644
--- a/src/video/directfb/SDL_DirectFB_events.c
+++ b/src/video/directfb/SDL_DirectFB_events.c
@@ -683,7 +683,7 @@ EnumKeyboards(DFBInputDeviceID device_id,
#endif
devdata->keyboard[de
(Patch may be truncated, please check the link at the top of this post.)