Give the heap-allocated Utf8Encode a unique function name

This commit is contained in:
Ethan Lee 2021-05-15 09:47:28 -04:00
parent a234470e39
commit e316ae5cfd
4 changed files with 28 additions and 28 deletions

View file

@ -66,7 +66,7 @@ namespace SDL2
/* Used for heap allocated string marshaling. /* Used for heap allocated string marshaling.
* Returned byte* must be free'd with FreeHGlobal. * Returned byte* must be free'd with FreeHGlobal.
*/ */
internal static unsafe byte* Utf8Encode(string str) internal static unsafe byte* Utf8EncodeHeap(string str)
{ {
Debug.Assert(str != null); Debug.Assert(str != null);
int bufferSize = Utf8Size(str); int bufferSize = Utf8Size(str);
@ -237,8 +237,8 @@ namespace SDL2
string file, string file,
string mode string mode
) { ) {
byte* utf8File = Utf8Encode(file); byte* utf8File = Utf8EncodeHeap(file);
byte* utf8Mode = Utf8Encode(mode); byte* utf8Mode = Utf8EncodeHeap(mode);
IntPtr rwOps = INTERNAL_SDL_RWFromFile( IntPtr rwOps = INTERNAL_SDL_RWFromFile(
utf8File, utf8File,
utf8Mode utf8Mode
@ -372,7 +372,7 @@ namespace SDL2
private static extern unsafe IntPtr INTERNAL_SDL_LoadFile(byte* file, out IntPtr datasize); private static extern unsafe IntPtr INTERNAL_SDL_LoadFile(byte* file, out IntPtr datasize);
public static unsafe IntPtr SDL_LoadFile(string file, out IntPtr datasize) public static unsafe IntPtr SDL_LoadFile(string file, out IntPtr datasize)
{ {
byte* utf8File = Utf8Encode(file); byte* utf8File = Utf8EncodeHeap(file);
IntPtr result = INTERNAL_SDL_LoadFile(utf8File, out datasize); IntPtr result = INTERNAL_SDL_LoadFile(utf8File, out datasize);
Marshal.FreeHGlobal((IntPtr) utf8File); Marshal.FreeHGlobal((IntPtr) utf8File);
return result; return result;
@ -1777,7 +1777,7 @@ namespace SDL2
private static extern unsafe int INTERNAL_SDL_GL_LoadLibrary(byte* path); private static extern unsafe int INTERNAL_SDL_GL_LoadLibrary(byte* path);
public static unsafe int SDL_GL_LoadLibrary(string path) public static unsafe int SDL_GL_LoadLibrary(string path)
{ {
byte* utf8Path = Utf8Encode(path); byte* utf8Path = Utf8EncodeHeap(path);
int result = INTERNAL_SDL_GL_LoadLibrary( int result = INTERNAL_SDL_GL_LoadLibrary(
utf8Path utf8Path
); );
@ -2152,7 +2152,7 @@ namespace SDL2
); );
public static unsafe int SDL_Vulkan_LoadLibrary(string path) public static unsafe int SDL_Vulkan_LoadLibrary(string path)
{ {
byte* utf8Path = Utf8Encode(path); byte* utf8Path = Utf8EncodeHeap(path);
int result = INTERNAL_SDL_Vulkan_LoadLibrary( int result = INTERNAL_SDL_Vulkan_LoadLibrary(
utf8Path utf8Path
); );
@ -4378,7 +4378,7 @@ namespace SDL2
public static unsafe int SDL_SetClipboardText( public static unsafe int SDL_SetClipboardText(
string text string text
) { ) {
byte* utf8Text = Utf8Encode(text); byte* utf8Text = Utf8EncodeHeap(text);
int result = INTERNAL_SDL_SetClipboardText( int result = INTERNAL_SDL_SetClipboardText(
utf8Text utf8Text
); );
@ -6507,7 +6507,7 @@ namespace SDL2
public static unsafe int SDL_GameControllerAddMapping( public static unsafe int SDL_GameControllerAddMapping(
string mappingString string mappingString
) { ) {
byte* utf8MappingString = Utf8Encode(mappingString); byte* utf8MappingString = Utf8EncodeHeap(mappingString);
int result = INTERNAL_SDL_GameControllerAddMapping( int result = INTERNAL_SDL_GameControllerAddMapping(
utf8MappingString utf8MappingString
); );
@ -7902,7 +7902,7 @@ namespace SDL2
public static unsafe SDL_bool SDL_AndroidRequestPermission( public static unsafe SDL_bool SDL_AndroidRequestPermission(
string permission string permission
) { ) {
byte* permissionPtr = Utf8Encode(permission); byte* permissionPtr = Utf8EncodeHeap(permission);
SDL_bool result = INTERNAL_SDL_AndroidRequestPermission( SDL_bool result = INTERNAL_SDL_AndroidRequestPermission(
permissionPtr permissionPtr
); );
@ -8225,7 +8225,7 @@ namespace SDL2
private static unsafe extern int INTERNAL_SDL_OpenURL(byte* url); private static unsafe extern int INTERNAL_SDL_OpenURL(byte* url);
public static unsafe int SDL_OpenURL(string url) public static unsafe int SDL_OpenURL(string url)
{ {
byte* urlPtr = Utf8Encode(url); byte* urlPtr = Utf8EncodeHeap(url);
int result = INTERNAL_SDL_OpenURL(urlPtr); int result = INTERNAL_SDL_OpenURL(urlPtr);
Marshal.FreeHGlobal((IntPtr) urlPtr); Marshal.FreeHGlobal((IntPtr) urlPtr);
return result; return result;

View file

@ -94,7 +94,7 @@ namespace SDL2
); );
public static unsafe IntPtr IMG_Load(string file) public static unsafe IntPtr IMG_Load(string file)
{ {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_IMG_Load( IntPtr handle = INTERNAL_IMG_Load(
utf8File utf8File
); );
@ -142,7 +142,7 @@ namespace SDL2
IntPtr renderer, IntPtr renderer,
string file string file
) { ) {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_IMG_LoadTexture( IntPtr handle = INTERNAL_IMG_LoadTexture(
renderer, renderer,
utf8File utf8File
@ -181,7 +181,7 @@ namespace SDL2
int freesrc, int freesrc,
string type string type
) { ) {
byte* utf8Type = SDL.Utf8Encode(type); byte* utf8Type = SDL.Utf8EncodeHeap(type);
IntPtr handle = INTERNAL_IMG_LoadTextureTyped_RW( IntPtr handle = INTERNAL_IMG_LoadTextureTyped_RW(
renderer, renderer,
src, src,
@ -207,7 +207,7 @@ namespace SDL2
); );
public static unsafe int IMG_SavePNG(IntPtr surface, string file) public static unsafe int IMG_SavePNG(IntPtr surface, string file)
{ {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
int result = INTERNAL_IMG_SavePNG( int result = INTERNAL_IMG_SavePNG(
surface, surface,
utf8File utf8File
@ -234,7 +234,7 @@ namespace SDL2
); );
public static unsafe int IMG_SaveJPG(IntPtr surface, string file, int quality) public static unsafe int IMG_SaveJPG(IntPtr surface, string file, int quality)
{ {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
int result = INTERNAL_IMG_SaveJPG( int result = INTERNAL_IMG_SaveJPG(
surface, surface,
utf8File, utf8File,

View file

@ -205,7 +205,7 @@ namespace SDL2
); );
public static unsafe IntPtr Mix_LoadMUS(string file) public static unsafe IntPtr Mix_LoadMUS(string file)
{ {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_Mix_LoadMUS( IntPtr handle = INTERNAL_Mix_LoadMUS(
utf8File utf8File
); );
@ -579,7 +579,7 @@ namespace SDL2
); );
public static unsafe int Mix_SetMusicCMD(string command) public static unsafe int Mix_SetMusicCMD(string command)
{ {
byte* utf8Cmd = SDL.Utf8Encode(command); byte* utf8Cmd = SDL.Utf8EncodeHeap(command);
int result = INTERNAL_Mix_SetMusicCMD( int result = INTERNAL_Mix_SetMusicCMD(
utf8Cmd utf8Cmd
); );
@ -599,7 +599,7 @@ namespace SDL2
); );
public static unsafe int Mix_SetSoundFonts(string paths) public static unsafe int Mix_SetSoundFonts(string paths)
{ {
byte* utf8Paths = SDL.Utf8Encode(paths); byte* utf8Paths = SDL.Utf8EncodeHeap(paths);
int result = INTERNAL_Mix_SetSoundFonts( int result = INTERNAL_Mix_SetSoundFonts(
utf8Paths utf8Paths
); );

View file

@ -101,7 +101,7 @@ namespace SDL2
); );
public static unsafe IntPtr TTF_OpenFont(string file, int ptsize) public static unsafe IntPtr TTF_OpenFont(string file, int ptsize)
{ {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_TTF_OpenFont( IntPtr handle = INTERNAL_TTF_OpenFont(
utf8File, utf8File,
ptsize ptsize
@ -131,7 +131,7 @@ namespace SDL2
int ptsize, int ptsize,
long index long index
) { ) {
byte* utf8File = SDL.Utf8Encode(file); byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_TTF_OpenFontIndex( IntPtr handle = INTERNAL_TTF_OpenFontIndex(
utf8File, utf8File,
ptsize, ptsize,
@ -302,7 +302,7 @@ namespace SDL2
out int w, out int w,
out int h out int h
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
int result = INTERNAL_TTF_SizeUTF8( int result = INTERNAL_TTF_SizeUTF8(
font, font,
utf8Text, utf8Text,
@ -354,7 +354,7 @@ namespace SDL2
out int extent, out int extent,
out int count out int count
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
int result = INTERNAL_TTF_MeasureUTF8( int result = INTERNAL_TTF_MeasureUTF8(
font, font,
utf8Text, utf8Text,
@ -400,7 +400,7 @@ namespace SDL2
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Solid( IntPtr result = INTERNAL_TTF_RenderUTF8_Solid(
font, font,
utf8Text, utf8Text,
@ -447,7 +447,7 @@ namespace SDL2
SDL.SDL_Color fg, SDL.SDL_Color fg,
uint wrapLength uint wrapLength
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Solid_Wrapped( IntPtr result = INTERNAL_TTF_RenderUTF8_Solid_Wrapped(
font, font,
utf8Text, utf8Text,
@ -512,7 +512,7 @@ namespace SDL2
SDL.SDL_Color fg, SDL.SDL_Color fg,
SDL.SDL_Color bg SDL.SDL_Color bg
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded( IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded(
font, font,
utf8Text, utf8Text,
@ -562,7 +562,7 @@ namespace SDL2
SDL.SDL_Color bg, SDL.SDL_Color bg,
uint wrapLength uint wrapLength
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded_Wrapped( IntPtr result = INTERNAL_TTF_RenderUTF8_Shaded_Wrapped(
font, font,
utf8Text, utf8Text,
@ -626,7 +626,7 @@ namespace SDL2
string text, string text,
SDL.SDL_Color fg SDL.SDL_Color fg
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Blended( IntPtr result = INTERNAL_TTF_RenderUTF8_Blended(
font, font,
utf8Text, utf8Text,
@ -669,7 +669,7 @@ namespace SDL2
SDL.SDL_Color fg, SDL.SDL_Color fg,
uint wrapped uint wrapped
) { ) {
byte* utf8Text = SDL.Utf8Encode(text); byte* utf8Text = SDL.Utf8EncodeHeap(text);
IntPtr result = INTERNAL_TTF_RenderUTF8_Blended_Wrapped( IntPtr result = INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
font, font,
utf8Text, utf8Text,