Skip to content

Commit 70db2b7

Browse files
committed
further improve GlobalHandle
1 parent cf86b1c commit 70db2b7

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

source/GlobalHandle.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,16 @@ template <typename T = void*> class GlobalHandleLock {
4040
throw std::runtime_error("Failed to Free Resource Handle");
4141
}
4242
}
43-
} else {
44-
if (!GlobalUnlock(globalHandle)) {
45-
if (GetLastError() != NO_ERROR) {
46-
throw std::runtime_error("Failed to Unlock Global Handle");
47-
}
43+
return;
44+
}
4845

49-
if (GlobalFree(globalHandle) != NULL) {
50-
throw std::runtime_error("Failed to Free Global Handle");
51-
}
46+
if (!GlobalUnlock(globalHandle)) {
47+
if (GetLastError() != NO_ERROR) {
48+
throw std::runtime_error("Failed to Unlock Global Handle");
49+
}
50+
51+
if (GlobalFree(globalHandle) != NULL) {
52+
throw std::runtime_error("Failed to Free Global Handle");
5253
}
5354
}
5455
#endif
@@ -160,10 +161,7 @@ template <typename T = void*> class GlobalHandleLock {
160161
return GetHandleSize(globalHandle);
161162
#endif
162163
#ifdef WINDOWS
163-
if (resource) {
164-
return resourceSize;
165-
}
166-
return GlobalSize(globalHandle);
164+
return resource ? resourceSize : GlobalSize(globalHandle);
167165
#endif
168166
}
169167

0 commit comments

Comments
 (0)