02.01.2015 Views

CooCox CoOS User's Guide

CooCox CoOS User's Guide

CooCox CoOS User's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6.5.2 CoKfree()<br />

Function Prototype:<br />

void CoKfree<br />

(<br />

void* memBuf<br />

);<br />

Description:<br />

Release the memory block with the initial address memBuf.<br />

Parameters:<br />

[IN] memBuf<br />

The initial address of the memory block which needs to be released<br />

Returns:<br />

None<br />

Example usage:<br />

#include "CCRTOS.h"<br />

void TaskN (void *pdata)<br />

{<br />

unsigned int *ptr;<br />

...<br />

/* Allocate 20 words of memory block from kernel heap */<br />

ptr = (unsigned int *)CoKmalloc(20*4);<br />

/* process ptr here */<br />

...<br />

/* Release memory block to kernel heap */<br />

CoKfree(ptr);<br />

...<br />

}<br />

Note:<br />

MemBuf must be obtained by CoKmalloc(), or it will do nothing and<br />

return immediately.<br />

6.5.3 CoCreateMemPartition()<br />

Function Prototype:<br />

OS_MMID CoCreateMemPartition<br />

(<br />

U8* memBuf,<br />

U32 blockSize,<br />

U32 blockNum<br />

);<br />

70

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!