Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ StringToHGlobalAnsi()

static unsafe IntPtr System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi ( string? s)
inlinestatic

Definition at line 1293 of file Marshal.cs.

1294 {
1295 if (s == null)
1296 {
1297 return IntPtr.Zero;
1298 }
1299 long num = (long)(s.Length + 1) * (long)SystemMaxDBCSCharSize;
1300 int num2 = (int)num;
1301 if (num2 != num)
1302 {
1303 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.s);
1304 }
1305 IntPtr intPtr = AllocHGlobal((IntPtr)num2);
1306 StringToAnsiString(s, (byte*)(void*)intPtr, num2);
1307 return intPtr;
1308 }
static unsafe int StringToAnsiString(string s, byte *buffer, int bufferLength, bool bestFit=false, bool throwOnUnmappableChar=false)
Definition Marshal.cs:1608
static readonly int SystemMaxDBCSCharSize
Definition Marshal.cs:19
static IntPtr AllocHGlobal(int cb)
Definition Marshal.cs:625

References System.Runtime.InteropServices.Marshal.AllocHGlobal(), System.s, System.Runtime.InteropServices.Marshal.StringToAnsiString(), System.Runtime.InteropServices.Marshal.SystemMaxDBCSCharSize, System.ThrowHelper.ThrowArgumentOutOfRangeException(), and System.IntPtr.Zero.

Referenced by Internal.Cryptography.CngAsnFormatter.FormatNative(), and Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue().