Skip to content

Commit

Permalink
Add 'const' to pointer parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Sackzement authored and slouken committed Feb 21, 2025
1 parent 911e53d commit b5297de
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/audio/SDL_audioresample.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ static void SincTable(float *table, int len)
}

// Calculate Sinc(x/y), using a lookup table
static float Sinc(float *table, int x, int y)
static float Sinc(const float *table, int x, int y)
{
float s = table[x % y];
s = ((x / y) & 1) ? -s : s;
Expand Down
12 changes: 6 additions & 6 deletions src/audio/alsa/SDL_alsa_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ static enum snd_pcm_chmap_position sdl_channel_maps[SDL_AUDIO_ALSA__SDL_CHMAPS_N
};

// Helper for the function right below.
static bool has_pos(unsigned int *chmap, unsigned int pos)
static bool has_pos(const unsigned int *chmap, unsigned int pos)
{
for (unsigned int chan_idx = 0; ; chan_idx++) {
if (chan_idx == 6) {
Expand All @@ -586,7 +586,7 @@ static bool has_pos(unsigned int *chmap, unsigned int pos)
#define HAVE_REAR 1
#define HAVE_SIDE 2
#define HAVE_BOTH 3
static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int *sdl_6chans, unsigned int *alsa_6chans)
static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int *sdl_6chans, const unsigned int *alsa_6chans)
{
// For alsa channel maps with 6 channels and with SND_CHMAP_FL,SND_CHMAP_FR,SND_CHMAP_FC,
// SND_CHMAP_LFE, reduce our 6 channels maps to a uniq one.
Expand Down Expand Up @@ -638,7 +638,7 @@ static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int *
#undef HAVE_SIDE
#undef HAVE_BOTH

static void swizzle_map_compute_alsa_subscan(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, unsigned int sdl_pos_idx)
static void swizzle_map_compute_alsa_subscan(const struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, unsigned int sdl_pos_idx)
{
swizzle_map[sdl_pos_idx] = -1;
for (unsigned int alsa_pos_idx = 0; ; alsa_pos_idx++) {
Expand All @@ -652,7 +652,7 @@ static void swizzle_map_compute_alsa_subscan(struct ALSA_pcm_cfg_ctx *ctx, int *
}

// XXX: this must stay playback/recording symetric.
static void swizzle_map_compute(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, bool *needs_swizzle)
static void swizzle_map_compute(const struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, bool *needs_swizzle)
{
*needs_swizzle = false;
for (unsigned int sdl_pos_idx = 0; sdl_pos_idx != ctx->chans_n; sdl_pos_idx++) {
Expand All @@ -668,7 +668,7 @@ static void swizzle_map_compute(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map,
#define CHMAP_NOT_FOUND 2
// Should always be a queried alsa channel map unless the queried alsa channel map was of type VAR,
// namely we can program the channel positions directly from the SDL channel map.
static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *chmap)
static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *chmap)
{
bool isstack;
snd_pcm_chmap_t *chmap_to_install = (snd_pcm_chmap_t*)SDL_small_alloc(unsigned int, 1 + ctx->chans_n, &isstack);
Expand Down Expand Up @@ -698,7 +698,7 @@ static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *chmap)

// We restrict the alsa channel maps because in the unordered matches we do only simple accounting.
// In the end, this will handle mostly alsa channel maps with more than one SND_CHMAP_NA position fillers.
static bool alsa_chmap_has_duplicate_position(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *pos)
static bool alsa_chmap_has_duplicate_position(const struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *pos)
{
if (ctx->chans_n < 2) {// we need at least 2 positions
LOGDEBUG("channel map:no duplicate");
Expand Down
4 changes: 2 additions & 2 deletions src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,7 @@ static void VULKAN_INTERNAL_RemoveMemoryUsedRegion(

static bool VULKAN_INTERNAL_CheckMemoryTypeArrayUnique(
Uint32 memoryTypeIndex,
Uint32 *memoryTypeIndexArray,
const Uint32 *memoryTypeIndexArray,
Uint32 count)
{
Uint32 i = 0;
Expand Down Expand Up @@ -4448,7 +4448,7 @@ static bool VULKAN_INTERNAL_VerifySwapSurfaceFormat(

static bool VULKAN_INTERNAL_VerifySwapPresentMode(
VkPresentModeKHR presentMode,
VkPresentModeKHR *availablePresentModes,
const VkPresentModeKHR *availablePresentModes,
Uint32 availablePresentModesLength)
{
Uint32 i;
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/SDL_gamepad.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ static bool SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event)
orientation, so when it's changed orientation to be used as a
gamepad, change the sensor orientation to match.
*/
static void AdjustSensorOrientation(SDL_Joystick *joystick, float *src, float *dst)
static void AdjustSensorOrientation(const SDL_Joystick *joystick, const float *src, float *dst)
{
unsigned int i, j;

Expand Down
2 changes: 1 addition & 1 deletion src/video/wayland/SDL_waylanddatamanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSo
}
}

static void *Wayland_clone_data_buffer(const void *buffer, size_t *len)
static void *Wayland_clone_data_buffer(const void *buffer, const size_t *len)
{
void *clone = NULL;
if (*len > 0 && buffer) {
Expand Down
2 changes: 1 addition & 1 deletion test/testgpu_spinning_cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r)
* major. In-place multiplication is supported.
*/
static void
multiply_matrix(float *lhs, float *rhs, float *r)
multiply_matrix(const float *lhs, const float *rhs, float *r)
{
int i, j, k;
float tmp[16];
Expand Down

0 comments on commit b5297de

Please sign in to comment.