Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
openMMC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
openMMC
Commits
764c2645
Commit
764c2645
authored
Feb 22, 2016
by
Henrique Silva
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include Calloc and Realloc functions
parent
9dc2dca1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
+43
-0
heap_4.c
FreeRTOS/heap_4.c
+41
-0
portable.h
FreeRTOS/include/portable.h
+2
-0
No files found.
FreeRTOS/heap_4.c
View file @
764c2645
...
...
@@ -349,6 +349,47 @@ BlockLink_t *pxLink;
}
/*-----------------------------------------------------------*/
#include "string.h"
void
*
pvPortCalloc
(
size_t
count
,
size_t
size
)
{
void
*
p
;
/* allocate 'count' objects of size 'size' */
p
=
pvPortMalloc
(
count
*
size
);
if
(
p
)
{
/* zero the memory */
memset
(
p
,
0
,
count
*
size
);
}
return
p
;
}
void
*
calloc
(
size_t
count
,
size_t
nbytes
)
__attribute__
((
alias
(
"pvPortCalloc"
)));
/*-----------------------------------------------------------*/
void
*
pvPortRealloc
(
void
*
mem
,
size_t
newsize
)
{
void
*
p
;
p
=
pvPortMalloc
(
newsize
);
if
(
p
)
{
/* Copy the contents of the old region */
if
(
mem
!=
NULL
)
{
memcpy
(
p
,
mem
,
newsize
);
vPortFree
(
mem
);
}
}
return
p
;
}
void
*
realloc
(
void
*
ptr
,
size_t
nbytes
)
__attribute__
((
alias
(
"pvPortRealloc"
)));
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
size_t
xPortGetFreeHeapSize
(
void
)
{
return
xFreeBytesRemaining
;
...
...
FreeRTOS/include/portable.h
View file @
764c2645
...
...
@@ -162,6 +162,8 @@ void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions );
*/
void
*
pvPortMalloc
(
size_t
xSize
)
PRIVILEGED_FUNCTION
;
void
vPortFree
(
void
*
pv
)
PRIVILEGED_FUNCTION
;
void
*
pvPortCalloc
(
size_t
count
,
size_t
size
)
PRIVILEGED_FUNCTION
;
void
*
pvPortRealloc
(
void
*
mem
,
size_t
newsize
)
PRIVILEGED_FUNCTION
;
void
vPortInitialiseBlocks
(
void
)
PRIVILEGED_FUNCTION
;
size_t
xPortGetFreeHeapSize
(
void
)
PRIVILEGED_FUNCTION
;
size_t
xPortGetMinimumEverFreeHeapSize
(
void
)
PRIVILEGED_FUNCTION
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment