1
- // Copyright (c) 2017-2021 , Mudita Sp. z.o.o. All rights reserved.
1
+ // Copyright (c) 2017-2022 , Mudita Sp. z.o.o. All rights reserved.
2
2
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
3
3
4
4
//
12
12
13
13
#include "memory/usermem.h"
14
14
15
-
16
15
void free (void * pv )
17
16
{
18
17
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
19
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
20
- memleaks_log_free ((uint32_t )pv ,caller );
18
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
19
+ memleaks_log_free ((uint32_t )pv , caller );
21
20
#endif
22
21
return userfree (pv );
23
22
}
24
23
25
24
void * malloc (size_t xWantedSize )
26
25
{
27
- void * ptr = usermalloc (xWantedSize );
26
+ void * ptr = usermalloc (xWantedSize );
28
27
29
28
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
30
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
31
- memleaks_log_malloc ((uint32_t )ptr ,(uint32_t )caller ,xWantedSize );
29
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
30
+ memleaks_log_malloc ((uint32_t )ptr , (uint32_t )caller , xWantedSize );
32
31
#endif
33
32
34
33
return ptr ;
35
34
}
36
35
37
- void * _malloc_r (struct _reent * r , size_t sz )
36
+ void * _malloc_r (struct _reent * r , size_t sz )
38
37
{
39
- void * ptr = usermalloc (sz );
38
+ void * ptr = usermalloc (sz );
40
39
41
40
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
42
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
43
- memleaks_log_malloc ((uint32_t )ptr ,(uint32_t )caller ,sz );
41
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
42
+ memleaks_log_malloc ((uint32_t )ptr , (uint32_t )caller , sz );
44
43
#endif
45
44
46
45
return ptr ;
47
46
}
48
47
49
- void * calloc (size_t num , size_t size )
48
+ void * calloc (size_t num , size_t size )
50
49
{
51
50
size_t total = num * size ;
52
- void * p = usermalloc (total );
51
+ void * p = usermalloc (total );
53
52
54
53
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
55
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
56
- memleaks_log_malloc ((uint32_t )p ,(uint32_t )caller ,total );
54
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
55
+ memleaks_log_malloc ((uint32_t )p , (uint32_t )caller , total );
57
56
#endif
58
57
59
- if (!p ) return NULL ;
58
+ if (!p )
59
+ return NULL ;
60
60
61
61
return memset (p , 0 , total );
62
62
}
@@ -66,32 +66,32 @@ void *realloc(void *aptr, size_t nbytes)
66
66
return userrealloc (aptr , nbytes );
67
67
}
68
68
69
-
70
- void * _calloc_r (struct _reent * r , size_t a , size_t b )
69
+ void * _calloc_r (struct _reent * r , size_t a , size_t b )
71
70
{
72
71
size_t total = a * b ;
73
- void * p = usermalloc (total );
72
+ void * p = usermalloc (total );
74
73
75
74
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
76
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
77
- memleaks_log_malloc ((uint32_t )p ,(uint32_t )caller ,total );
75
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
76
+ memleaks_log_malloc ((uint32_t )p , (uint32_t )caller , total );
78
77
#endif
79
78
80
- if (!p ) return NULL ;
79
+ if (!p )
80
+ return NULL ;
81
81
82
82
return memset (p , 0 , total );
83
83
}
84
84
85
- void _free_r (struct _reent * r , void * x )
85
+ void _free_r (struct _reent * r , void * x )
86
86
{
87
87
#if PROJECT_CONFIG_MEM_LEAKS_CHECKS == 1
88
- uint32_t caller = (uint32_t )__builtin_return_address (0 );
89
- memleaks_log_free ((uint32_t )x ,caller );
88
+ uint32_t caller = (uint32_t )__builtin_return_address (0 );
89
+ memleaks_log_free ((uint32_t )x , caller );
90
90
#endif
91
91
return userfree (x );
92
92
}
93
93
94
- void * _realloc_r (struct _reent * r , void * x , size_t sz )
94
+ void * _realloc_r (struct _reent * r , void * x , size_t sz )
95
95
{
96
96
return realloc (x , sz );
97
97
}
0 commit comments