Skip to content

Commit

Permalink
Merge pull request #1 from aronson/cleanup
Browse files Browse the repository at this point in the history
Only seek MSVCRT!free once at launch
  • Loading branch information
aronson authored Jul 7, 2023
2 parents d078c5c + 87dd659 commit c49b088
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/SDL12_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

/* This file contains functions for backwards compatibility with SDL 1.2 */


#include "SDL20_include_wrapper.h"

/*
Expand Down Expand Up @@ -8490,13 +8489,18 @@ SDL_LoadWAV_RW(SDL12_RWops *rwops12, int freerwops12,
return retval;
}

typedef void (*free_t)(void *);
static free_t msvcrt_free = NULL;

DECLSPEC void SDLCALL
SDL_FreeWAV (Uint8 *audio_buf)
{
if ( msvcrt_free == NULL ) {
msvcrt_free = (free_t)(GetProcAddress(GetModuleHandle(TEXT("msvcrt")), "free"));
}

if ( audio_buf != NULL ) {
typedef void (*free_t)(void *);
free_t msvcrt_free = (free_t)(GetProcAddress(GetModuleHandle(TEXT("msvcrt")), "free"));
msvcrt_free(audio_buf);
msvcrt_free(audio_buf);
}
}

Expand Down

0 comments on commit c49b088

Please sign in to comment.