Object table handle duplication

This commit is contained in:
Dr. Chat 2015-06-09 18:58:02 -05:00
parent dbcdc5b543
commit 3627418e0e
2 changed files with 16 additions and 0 deletions

View File

@ -112,6 +112,21 @@ X_STATUS ObjectTable::AddHandle(XObject* object, X_HANDLE* out_handle) {
return result; return result;
} }
X_STATUS ObjectTable::DuplicateHandle(X_HANDLE handle, X_HANDLE* out_handle) {
X_STATUS result = X_STATUS_SUCCESS;
handle = TranslateHandle(handle);
XObject* object = LookupObject(handle, false);
if (object) {
result = AddHandle(object, out_handle);
object->Release(); // Release the ref that LookupObject took
} else {
result = X_STATUS_INVALID_HANDLE;
}
return result;
}
X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) { X_STATUS ObjectTable::RemoveHandle(X_HANDLE handle) {
X_STATUS result = X_STATUS_SUCCESS; X_STATUS result = X_STATUS_SUCCESS;

View File

@ -27,6 +27,7 @@ class ObjectTable {
~ObjectTable(); ~ObjectTable();
X_STATUS AddHandle(XObject* object, X_HANDLE* out_handle); X_STATUS AddHandle(XObject* object, X_HANDLE* out_handle);
X_STATUS DuplicateHandle(X_HANDLE orig, X_HANDLE* out_handle);
X_STATUS RemoveHandle(X_HANDLE handle); X_STATUS RemoveHandle(X_HANDLE handle);
template <typename T> template <typename T>
object_ref<T> LookupObject(X_HANDLE handle) { object_ref<T> LookupObject(X_HANDLE handle) {