Avoid duplicate object handle assignment on creation.

This commit is contained in:
Ben Vanik 2015-12-29 14:03:23 -08:00
parent 9c694f07b3
commit 3ca0bff246
2 changed files with 4 additions and 6 deletions

View File

@ -96,8 +96,6 @@ bool ObjectTable::Resize(uint32_t new_capacity) {
} }
X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) { X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
assert_not_null(out_handle);
X_STATUS result = X_STATUS_SUCCESS; X_STATUS result = X_STATUS_SUCCESS;
uint32_t handle = 0; uint32_t handle = 0;
@ -123,8 +121,10 @@ X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
} }
if (XSUCCEEDED(result)) { if (XSUCCEEDED(result)) {
if (out_handle) {
*out_handle = handle; *out_handle = handle;
} }
}
return result; return result;
} }

View File

@ -42,9 +42,7 @@ XObject::XObject(KernelState* kernel_state, Type type)
// TODO: Assert kernel_state != nullptr in this constructor. // TODO: Assert kernel_state != nullptr in this constructor.
if (kernel_state) { if (kernel_state) {
X_HANDLE handle; kernel_state->object_table()->AddHandle(this, nullptr);
kernel_state->object_table()->AddHandle(this, &handle);
handles_[0] = handle;
} }
} }