Skip to content

Commit 3126ba4

Browse files
EgorBoCopilot
andcommitted
Use named InlineArray types for constant-sized buffers
Co-authored-by: Copilot <[email protected]> Copilot-Session: 974e15bd-cff2-4970-9a39-bab5fd0e2cee
1 parent c89d421 commit 3126ba4

4 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎src/libraries/Common/src/Interop/OSX/Interop.libproc.GetProcessInfoById.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal struct proc_bsdinfo
3131
internal uint pbi_svuid;
3232
internal uint pbi_svgid;
3333
internal uint reserved;
34-
internal InlineArray16<byte> pbi_comm; // MAXCOMLEN
34+
internal CommBuffer pbi_comm;
3535
internal NameBuffer pbi_name;
3636
internal uint pbi_nfiles;
3737
internal uint pbi_pgid;
@@ -42,6 +42,12 @@ internal struct proc_bsdinfo
4242
internal ulong pbi_start_tvsec;
4343
internal ulong pbi_start_tvusec;
4444

45+
[InlineArray(MAXCOMLEN)]
46+
internal struct CommBuffer
47+
{
48+
private byte _element0;
49+
}
50+
4551
[InlineArray(MAXCOMLEN * 2)]
4652
internal struct NameBuffer
4753
{

‎src/libraries/Common/src/Interop/Unix/System.Native/Interop.IPAddress.cs‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public bool IsIPv6
2929
set { _isIPv6 = value ? 1u : 0u; }
3030
}
3131

32-
internal InlineArray16<byte> Address; // Buffer to fit an IPv4 or IPv6 address (MAX_IP_ADDRESS_BYTES)
33-
private uint _isIPv6; // Non-zero if this is an IPv6 address; zero for IPv4.
34-
internal uint ScopeId; // Scope ID (IPv6 only)
32+
internal AddressBuffer Address; // Buffer to fit an IPv4 or IPv6 address
33+
private uint _isIPv6; // Non-zero if this is an IPv6 address; zero for IPv4.
34+
internal uint ScopeId; // Scope ID (IPv6 only)
3535

3636
public override int GetHashCode()
3737
{
@@ -71,6 +71,12 @@ public bool Equals(IPAddress other)
7171

7272
return Address[..addressByteCount].SequenceEqual(other.Address[..addressByteCount]);
7373
}
74+
75+
[InlineArray(MAX_IP_ADDRESS_BYTES)]
76+
internal struct AddressBuffer
77+
{
78+
private byte _element0;
79+
}
7480
}
7581
}
7682
}

‎src/libraries/Common/src/Interop/Windows/SspiCli/Interop.TokenSource.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ internal static partial class SspiCli
1212
[StructLayout(LayoutKind.Sequential)]
1313
internal struct TOKEN_SOURCE
1414
{
15-
internal InlineArray8<byte> SourceName; // TOKEN_SOURCE_LENGTH
15+
internal SourceNameBuffer SourceName;
1616
internal LUID SourceIdentifier;
1717

1818
internal const int TOKEN_SOURCE_LENGTH = 8;
19+
20+
[InlineArray(TOKEN_SOURCE_LENGTH)]
21+
internal struct SourceNameBuffer
22+
{
23+
private byte _element0;
24+
}
1925
}
2026
}
2127
}

‎src/libraries/Common/src/Interop/Windows/WinSock/Interop.WinsockAsync.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,14 @@ internal struct ControlDataIPv6
2828
internal UIntPtr length;
2929
internal uint level;
3030
internal uint type;
31-
internal InlineArray16<byte> address; // IPv6AddressLength
31+
internal AddressBuffer address;
3232
internal uint index;
33+
34+
[InlineArray(IPv6AddressLength)]
35+
internal struct AddressBuffer
36+
{
37+
private byte _element0;
38+
}
3339
}
3440

3541
// Flags equivalent to winsock TRANSMIT_PACKETS_ELEMENT flags

0 commit comments

Comments
 (0)