1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "device_token_proxy.h"
17 #include "osal_mem.h"
18 
HdfDevTokenProxyConstruct(struct HdfDevTokenProxy * inst,struct HdfRemoteService * remote)19 static void HdfDevTokenProxyConstruct(struct HdfDevTokenProxy *inst, struct HdfRemoteService *remote)
20 {
21     inst->remote = remote;
22 }
23 
HdfDevTokenProxyObtain(struct HdfRemoteService * remote)24 struct HdfDevTokenProxy *HdfDevTokenProxyObtain(struct HdfRemoteService *remote)
25 {
26     struct HdfDevTokenProxy *instance =
27         (struct HdfDevTokenProxy *)OsalMemCalloc(sizeof(struct HdfDevTokenProxy));
28     if (instance != NULL) {
29         HdfDevTokenProxyConstruct(instance, remote);
30     }
31     return instance;
32 }
33 
HdfDevTokenProxyRecycle(struct HdfDevTokenProxy * inst)34 void HdfDevTokenProxyRecycle(struct HdfDevTokenProxy *inst)
35 {
36     if (inst != NULL) {
37         if (inst->remote != NULL) {
38             HdfRemoteServiceRecycle(inst->remote);
39             inst->remote = NULL;
40         }
41         OsalMemFree((void *)inst->super.servName);
42         OsalMemFree((void *)inst->super.deviceName);
43         OsalMemFree(inst);
44     }
45 }
46 
47