Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WindowsController::GetExecutablePath 分配内存过大 #7

Closed
LYP951018 opened this issue Nov 9, 2015 · 1 comment
Closed

WindowsController::GetExecutablePath 分配内存过大 #7

LYP951018 opened this issue Nov 9, 2015 · 1 comment
Labels

Comments

@LYP951018
Copy link

MSDN

The Windows API has many functions that also have Unicode versions to permit an extended-length >path for a maximum total path length of 32,767 characters.

而源代码中分配了 65536 characters:

WString GetExecutablePath()
{
        Array<wchar_t> buffer(65536);
        GetModuleFileName(NULL, &buffer[0], (DWORD)buffer.Count());
        return &buffer[0];
}

而且有个小建议就是,可以一点一点试大小(MSDN评论里面的。。),毕竟长路径情况太少了。。。

@vczh
Copy link
Member

vczh commented Nov 12, 2015

反正是堆上的,没什么关系。如果你一定要变小的话,要不你改成32768然后pull request上来(逃

@vczh vczh closed this as completed Nov 12, 2015
@vczh vczh added the wontfix label Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants