Module: check_mk
Branch: master
Commit: 9d15042c3a5e2bfa83a1e26a6dbfd878f5566fab
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9d15042c3a5e2b…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Thu Jan 11 09:36:03 2018 +0100
Windows agent: avoid LocalAlloc when possible
If the use of LocalAlloc / LocalFree is not dictated by WinAPI, use
platform-indenpendent standard memory allocation instead.
Change-Id: Ia897347e4fbc6cbc7848b89daa539ff968bd77c2
---
agents/windows/build_version | 2 +-
agents/windows/sections/SectionServices.cc | 11 +++++------
2 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/agents/windows/build_version b/agents/windows/build_version
index 089bb23..9bcc9f4 100644
--- a/agents/windows/build_version
+++ b/agents/windows/build_version
@@ -1 +1 @@
-3056
+3058
diff --git a/agents/windows/sections/SectionServices.cc
b/agents/windows/sections/SectionServices.cc
index 89cdefb..80d6733 100644
--- a/agents/windows/sections/SectionServices.cc
+++ b/agents/windows/sections/SectionServices.cc
@@ -51,13 +51,12 @@ const char *SectionServices::serviceStartType(SC_HANDLE scm,
if (dwError == ERROR_INSUFFICIENT_BUFFER) {
start_type = "invalid4";
cbBufSize = dwBytesNeeded;
- LocalMemoryHandle<LPQUERY_SERVICE_CONFIGW> lpsc{
- reinterpret_cast<LPQUERY_SERVICE_CONFIGW>(
- _winapi.LocalAlloc(LMEM_FIXED, cbBufSize)),
- _winapi};
- if (_winapi.QueryServiceConfig(schService.get(), lpsc.get(),
+ std::vector<BYTE> buffer(cbBufSize, 0);
+ LPQUERY_SERVICE_CONFIGW lpsc =
+ reinterpret_cast<LPQUERY_SERVICE_CONFIGW>(buffer.data());
+ if (_winapi.QueryServiceConfig(schService.get(), lpsc,
cbBufSize, &dwBytesNeeded)) {
- switch (lpsc.get()->dwStartType) {
+ switch (lpsc->dwStartType) {
case SERVICE_AUTO_START:
start_type = "auto";
break;