1 /*
2 *
3 * Copyright 2013 Rockchip Electronics Co., LTD.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18 /*
19 * @file Rockchip_OSAL_Memory.h
20 * @brief
21 * @author csy(csy@rock-chips.com)
22 * @version 1.0.0
23 * @history
24 * 2013.11.26 : Create
25 */
26 #include <securec.h>
27 #include "Rockchip_OSAL_Memory.h"
28
29 #define ROCKCHIP_LOG_OFF
30 #include "Rockchip_OSAL_Log.h"
31
32 static int mem_cnt = 0;
33
Rockchip_OSAL_Malloc_With_Caller(OMX_U32 size,const char * tag,const char * caller,const OMX_U32 line)34 OMX_PTR Rockchip_OSAL_Malloc_With_Caller(
35 OMX_U32 size,
36 const char *tag,
37 const char *caller,
38 const OMX_U32 line)
39 {
40 mem_cnt++;
41 omx_dbg_f(OMX_DBG_MALLOC, "tag: %s, caller: %s(%d), malloc count: %d",
42 tag, caller, (int)line, mem_cnt);
43 if (size <= 0) {
44 printf("size error %s %d.\n", __FUNCTION__, __LINE__);
45 }
46 OMX_PTR omx_ptr = (OMX_PTR)malloc(size);
47 if (omx_ptr == NULL) {
48 printf("maloc error %s %d.\n", __FUNCTION__, __LINE__);
49 }
50 return omx_ptr;
51 }
52
Rockchip_OSAL_Free_With_Caller(OMX_PTR addr,const char * tag,const char * caller,const OMX_U32 line)53 void Rockchip_OSAL_Free_With_Caller(
54 OMX_PTR addr,
55 const char *tag,
56 const char *caller,
57 const OMX_U32 line)
58 {
59 if (addr) {
60 mem_cnt--;
61 omx_dbg_f(OMX_DBG_MALLOC, "tag: %s, caller: %s(%d), free count: %d",
62 tag, caller, (int)line, mem_cnt);
63 free(addr);
64 }
65
66 return;
67 }
68
Rockchip_OSAL_Memset(OMX_PTR dest,OMX_S32 c,OMX_S32 n)69 OMX_S32 Rockchip_OSAL_Memset(OMX_PTR dest, OMX_S32 c, OMX_S32 n)
70 {
71 return memset_s(dest, n, c, n);
72 }
73
Rockchip_OSAL_Memcpy(OMX_PTR dest,OMX_PTR src,OMX_S32 n)74 OMX_S32 Rockchip_OSAL_Memcpy(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
75 {
76 return memcpy_s(dest, n, src, n);
77 }
78
Rockchip_OSAL_Memmove(OMX_PTR dest,OMX_PTR src,OMX_S32 n)79 OMX_S32 Rockchip_OSAL_Memmove(OMX_PTR dest, OMX_PTR src, OMX_S32 n)
80 {
81 return memmove_s(dest, n, src, n);
82 }