On Friday, 11 July 2025 at 22:17:02 UTC, WhatMeWorry wrote:
```
// working function

SDL_Texture* changeTextureAccess(SDL_Texture *texture, SDL_TextureAccess newAccess)
{
    // pertinent code only
texture = createTexture(renderer, pixelFormat, newAccess, width, height);
    return texture;
}
```

The above function is working for me when I call it with:
```
SDL_Texture* sameTexture = changeTextureAccess(sameTexture, SDL_TEXTUREACCESS_STREAMING)
```
but I thought a better solution would be simply:
```
void changeTextureAccess(SDL_Texture **texture, SDL_TextureAccess newAccess)
```
Isn't the only way to update a function parameter is by making it a pointer?
So I thought something like
```
*texture = createTexture(renderer, pixelFormat, newAccess, width, height);
```
would work but that just leads to a whole bunch of other lines of code returning compiler errors. Am I at least on the right track here? I've been throwing lots of * and & all around and not getting anywhere?

You’re going in the right direction yes; SDL_Texture** would be a pointer to a SDL_Texture pointer; however such a pointer needs to be valid.

I would recommend using `ref`; eg `ref SDL_Texture*`; which would be safer given that the SDL_Texture* provided then has to be a valid variable to store the pointer into.

As for creating and dereferencing references; without seeing the errors in question I am not sure I can provide a good answer.

Reply via email to