1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * 4 * HDF is dual licensed: you can use it either under the terms of 5 * the GPL, or the BSD license, at your option. 6 * See the LICENSE file in the root of this repository for complete details. 7 */ 8 9 #include "hdf_object_manager.h" 10 HdfObjectManagerGetObject(int objectId)11struct HdfObject *HdfObjectManagerGetObject(int objectId) 12 { 13 struct HdfObject *object = NULL; 14 const struct HdfObjectCreator *targetCreator = HdfObjectManagerGetCreators(objectId); 15 if ((targetCreator != NULL) && (targetCreator->Create != NULL)) { 16 object = targetCreator->Create(); 17 if (object != NULL) { 18 object->objectId = objectId; 19 } 20 } 21 return object; 22 } 23 HdfObjectManagerFreeObject(struct HdfObject * object)24void HdfObjectManagerFreeObject(struct HdfObject *object) 25 { 26 const struct HdfObjectCreator *targetCreator = NULL; 27 if (object == NULL) { 28 return; 29 } 30 targetCreator = HdfObjectManagerGetCreators(object->objectId); 31 if ((targetCreator == NULL) || (targetCreator->Release == NULL)) { 32 return; 33 } 34 targetCreator->Release(object); 35 }