As written, this never frees any memory.
That block is the failure block and is a little confusing. On failure, you may prefer to
return NULL so you can detect failure and respond appropriately. As it is, you instead get a dummy texture that is not even the size you expected.
This creates a new texture, then returns it, ending processing of this function. The rest that follows the
return is unreachable code. The texture and surface are not freed. You do not really want to free the texture here anyhow, as the whole point of the function is to get a valid texture. If you destroy the texture, it won't be valid any more.
SDL_Texture* LoadTexture(string file)
SDL_Surface *image = IMG_Load(file.c_str());
cout << "Unable to load image:" << file.c_str() << " SDL_image Error: "<< IMG_GetError() << endl;
SDL_SetColorKey(image, SDL_TRUE, SDL_MapRGB(image->format, 255,0,255));
SDL_Texture *texture = SDL_CreateTextureFromSurface(ren, image );