aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/native/windows/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/native/windows/util.h')
-rw-r--r--src/main/native/windows/util.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/native/windows/util.h b/src/main/native/windows/util.h
index 730a1d46f9..5a647a4f37 100644
--- a/src/main/native/windows/util.h
+++ b/src/main/native/windows/util.h
@@ -49,6 +49,30 @@ struct AutoHandle {
HANDLE handle_;
};
+struct AutoAttributeList {
+ AutoAttributeList(DWORD dwAttributeCount) {
+ SIZE_T size = 0;
+ InitializeProcThreadAttributeList(NULL, dwAttributeCount, 0, &size);
+ lpAttributeList =
+ reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(malloc(size));
+ InitializeProcThreadAttributeList(lpAttributeList, dwAttributeCount, 0,
+ &size);
+ }
+
+ ~AutoAttributeList() {
+ if (lpAttributeList) {
+ DeleteProcThreadAttributeList(lpAttributeList);
+ free(lpAttributeList);
+ }
+ lpAttributeList = NULL;
+ }
+
+ operator LPPROC_THREAD_ATTRIBUTE_LIST() const { return lpAttributeList; }
+
+ private:
+ LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList;
+};
+
#define WSTR1(x) L##x
#define WSTR(x) WSTR1(x)