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

◆ ToLpstrArray()

static unsafe SafeHandle Internal.Cryptography.Pal.Native.Helpers.ToLpstrArray ( this OidCollection oids,
out int numOids )
inlinestatic

Definition at line 14 of file Helpers.cs.

15 {
16 if (oids == null || oids.Count == 0)
17 {
18 numOids = 0;
19 return SafePointerHandle<SafeLocalAllocHandle>.InvalidHandle;
20 }
21 string[] array = new string[oids.Count];
22 for (int i = 0; i < array.Length; i++)
23 {
24 array[i] = oids[i].Value;
25 }
26 SafeLocalAllocHandle safeLocalAllocHandle;
27 checked
28 {
29 int num = array.Length * sizeof(void*);
30 string[] array2 = array;
31 foreach (string text in array2)
32 {
33 num += text.Length + 1;
34 }
35 safeLocalAllocHandle = SafeLocalAllocHandle.Create(num);
36 }
37 byte** ptr = (byte**)(void*)safeLocalAllocHandle.DangerousGetHandle();
38 byte* ptr2 = (byte*)(ptr + array.Length);
39 for (int k = 0; k < array.Length; k++)
40 {
41 string text2 = array[k];
42 ptr[k] = ptr2;
43 int bytes = Encoding.ASCII.GetBytes(text2, new Span<byte>(ptr2, text2.Length));
44 ptr2[text2.Length] = 0;
45 ptr2 += text2.Length + 1;
46 }
47 numOids = array.Length;
48 return safeLocalAllocHandle;
49 }
static Encoding ASCII
Definition Encoding.cs:511

References System.array, System.Text.Encoding.ASCII, System.bytes, System.Security.Cryptography.OidCollection.Count, Internal.Cryptography.Pal.Native.SafeLocalAllocHandle.Create(), Internal.Cryptography.Pal.Native.SafePointerHandle< T >.InvalidHandle, and System.text.