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.
* 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);
int bufferSize = Utf8Size(str);
@ -237,8 +237,8 @@ namespace SDL2
string file,
string mode
) {
byte* utf8File = Utf8Encode(file);
byte* utf8Mode = Utf8Encode(mode);
byte* utf8File = Utf8EncodeHeap(file);
byte* utf8Mode = Utf8EncodeHeap(mode);
IntPtr rwOps = INTERNAL_SDL_RWFromFile(
utf8File,
utf8Mode
@ -372,7 +372,7 @@ namespace SDL2
private static extern unsafe IntPtr INTERNAL_SDL_LoadFile(byte* 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);
Marshal.FreeHGlobal((IntPtr) utf8File);
return result;
@ -1777,7 +1777,7 @@ namespace SDL2
private static extern unsafe int INTERNAL_SDL_GL_LoadLibrary(byte* path);
public static unsafe int SDL_GL_LoadLibrary(string path)
{
byte* utf8Path = Utf8Encode(path);
byte* utf8Path = Utf8EncodeHeap(path);
int result = INTERNAL_SDL_GL_LoadLibrary(
utf8Path
);
@ -2152,7 +2152,7 @@ namespace SDL2
);
public static unsafe int SDL_Vulkan_LoadLibrary(string path)
{
byte* utf8Path = Utf8Encode(path);
byte* utf8Path = Utf8EncodeHeap(path);
int result = INTERNAL_SDL_Vulkan_LoadLibrary(
utf8Path
);
@ -4378,7 +4378,7 @@ namespace SDL2
public static unsafe int SDL_SetClipboardText(
string text
) {
byte* utf8Text = Utf8Encode(text);
byte* utf8Text = Utf8EncodeHeap(text);
int result = INTERNAL_SDL_SetClipboardText(
utf8Text
);
@ -6507,7 +6507,7 @@ namespace SDL2
public static unsafe int SDL_GameControllerAddMapping(
string mappingString
) {
byte* utf8MappingString = Utf8Encode(mappingString);
byte* utf8MappingString = Utf8EncodeHeap(mappingString);
int result = INTERNAL_SDL_GameControllerAddMapping(
utf8MappingString
);
@ -7902,7 +7902,7 @@ namespace SDL2
public static unsafe SDL_bool SDL_AndroidRequestPermission(
string permission
) {
byte* permissionPtr = Utf8Encode(permission);
byte* permissionPtr = Utf8EncodeHeap(permission);
SDL_bool result = INTERNAL_SDL_AndroidRequestPermission(
permissionPtr
);
@ -8225,7 +8225,7 @@ namespace SDL2
private static unsafe extern int INTERNAL_SDL_OpenURL(byte* url);
public static unsafe int SDL_OpenURL(string url)
{
byte* urlPtr = Utf8Encode(url);
byte* urlPtr = Utf8EncodeHeap(url);
int result = INTERNAL_SDL_OpenURL(urlPtr);
Marshal.FreeHGlobal((IntPtr) urlPtr);
return result;

View file

@ -94,7 +94,7 @@ namespace SDL2
);
public static unsafe IntPtr IMG_Load(string file)
{
byte* utf8File = SDL.Utf8Encode(file);
byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_IMG_Load(
utf8File
);
@ -142,7 +142,7 @@ namespace SDL2
IntPtr renderer,
string file
) {
byte* utf8File = SDL.Utf8Encode(file);
byte* utf8File = SDL.Utf8EncodeHeap(file);
IntPtr handle = INTERNAL_IMG_LoadTexture(
renderer,
utf8File
@ -181,7 +181,7 @@ namespace SDL2
int freesrc,
string type
) {
byte* utf8Type = SDL.Utf8Encode(type);
byte* utf8Type = SDL.Utf8EncodeHeap(type);
IntPtr handle = INTERNAL_IMG_LoadTextureTyped_RW(
renderer,
src,
@ -207,7 +207,7 @@ namespace SDL2
);
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(
surface,
utf8File
@ -234,7 +234,7 @@ namespace SDL2
);
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(
surface,
utf8File,

View file

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

View file

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