1 /*
2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 * Description: 系统适配层内存接口实现源文件(此文件为DEMO,需集成方适配修改)
15 */
16 #include "hilink_mem_adapter.h"
17 #include <string.h>
18 #include <stdlib.h>
19
HILINK_Malloc(unsigned int size)20 void *HILINK_Malloc(unsigned int size)
21 {
22 if (size == 0) {
23 return NULL;
24 }
25
26 return malloc(size);
27 }
28
HILINK_Free(void * pt)29 void HILINK_Free(void *pt)
30 {
31 if (pt == NULL) {
32 return;
33 }
34 free(pt);
35 }
36
HILINK_Memcmp(const void * buf1,const void * buf2,unsigned int len)37 int HILINK_Memcmp(const void *buf1, const void *buf2, unsigned int len)
38 {
39 if ((buf1 == NULL) && (buf2 == NULL)) {
40 return 0;
41 }
42 if ((buf1 != NULL) && (buf2 == NULL)) {
43 return 1;
44 }
45 if ((buf1 == NULL) && (buf2 != NULL)) {
46 return -1;
47 }
48
49 return memcmp(buf1, buf2, len);
50 }