• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2022 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_device_token.h"
10 #include "hdf_object_manager.h"
11 #include "osal_mem.h"
12 
HdfDeviceTokenConstruct(struct HdfDeviceToken * inst)13 static void HdfDeviceTokenConstruct(struct HdfDeviceToken *inst)
14 {
15     inst->super.object.objectId = HDF_OBJECT_ID_DEVICE_TOKEN;
16 }
17 
HdfDeviceTokenCreate(void)18 struct HdfObject *HdfDeviceTokenCreate(void)
19 {
20     struct HdfDeviceToken *token =
21         (struct HdfDeviceToken *)OsalMemCalloc(sizeof(struct HdfDeviceToken));
22     if (token != NULL) {
23         HdfDeviceTokenConstruct(token);
24     }
25     return (struct HdfObject *)token;
26 }
27 
HdfDeviceTokenRelease(struct HdfObject * object)28 void HdfDeviceTokenRelease(struct HdfObject *object)
29 {
30     struct HdfDeviceToken *deviceToken = (struct HdfDeviceToken *)object;
31     if (deviceToken != NULL) {
32         OsalMemFree((void *)deviceToken->super.servName);
33         OsalMemFree((void *)deviceToken->super.deviceName);
34         OsalMemFree(deviceToken);
35     }
36 }
37 
HdfDeviceTokenNewInstance(void)38 struct IHdfDeviceToken *HdfDeviceTokenNewInstance(void)
39 {
40     return (struct IHdfDeviceToken *)HdfObjectManagerGetObject(HDF_OBJECT_ID_DEVICE_TOKEN);
41 }
42 
HdfDeviceTokenFreeInstance(struct IHdfDeviceToken * token)43 void HdfDeviceTokenFreeInstance(struct IHdfDeviceToken *token)
44 {
45     if (token != NULL) {
46         HdfObjectManagerFreeObject(&token->object);
47     }
48 }
49 
50