未验证 提交 c5327b22 编写于 作者: K Kevin Jones 提交者: GitHub

Use a constant for stackalloc (#68438)

上级 e99fb185
......@@ -165,16 +165,16 @@ internal static ErrorInfo GetLastErrorInfo()
internal static unsafe string StrError(int platformErrno)
{
int maxBufferLength = 1024; // should be long enough for most any UNIX error
byte* buffer = stackalloc byte[maxBufferLength];
byte* message = StrErrorR(platformErrno, buffer, maxBufferLength);
const int MaxBufferLength = 1024; // should be long enough for most any UNIX error
byte* buffer = stackalloc byte[MaxBufferLength];
byte* message = StrErrorR(platformErrno, buffer, MaxBufferLength);
if (message == null)
{
// This means the buffer was not large enough, but still contains
// as much of the error message as possible and is guaranteed to
// be null-terminated. We're not currently resizing/retrying because
// maxBufferLength is large enough in practice, but we could do
// MaxBufferLength is large enough in practice, but we could do
// so here in the future if necessary.
message = buffer;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册