• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "device_token_clnt.h"
10 #include "hdf_device_token.h"
11 #include "hdf_log.h"
12 #include "osal_mem.h"
13 
14 #define HDF_LOG_TAG device_token_clnt
15 
DeviceTokenClntConstruct(struct DeviceTokenClnt * tokenClnt,struct IHdfDeviceToken * tokenIf)16 static void DeviceTokenClntConstruct(struct DeviceTokenClnt *tokenClnt, struct IHdfDeviceToken *tokenIf)
17 {
18     tokenClnt->tokenIf = tokenIf;
19     tokenClnt->deviceInfo = NULL;
20 }
21 
DeviceTokenClntNewInstance(struct IHdfDeviceToken * tokenIf)22 struct DeviceTokenClnt *DeviceTokenClntNewInstance(struct IHdfDeviceToken *tokenIf)
23 {
24     struct DeviceTokenClnt *tokenClnt = NULL;
25     if (tokenIf == NULL) {
26         HDF_LOGE("failed to create token client, tokenIf is null");
27         return NULL;
28     }
29     tokenClnt = (struct DeviceTokenClnt *)OsalMemCalloc(sizeof(struct DeviceTokenClnt));
30     if (tokenClnt != NULL) {
31         DeviceTokenClntConstruct(tokenClnt, tokenIf);
32     }
33     return tokenClnt;
34 }
35 
DeviceTokenClntFreeInstance(struct DeviceTokenClnt * tokenClnt)36 void DeviceTokenClntFreeInstance(struct DeviceTokenClnt *tokenClnt)
37 {
38     if (tokenClnt != NULL) {
39         OsalMemFree(tokenClnt);
40     }
41 }
42 
DeviceTokenClntDelete(struct HdfSListNode * listEntry)43 void DeviceTokenClntDelete(struct HdfSListNode *listEntry)
44 {
45     struct DeviceTokenClnt *tokenClnt = (struct DeviceTokenClnt *)listEntry;
46     if (tokenClnt != NULL) {
47         DeviceTokenClntFreeInstance(tokenClnt);
48     }
49 }
50