Go to the documentation of this file.
32 #define TRACE_LEVEL MEM_TRACE_LEVEL
40 #if (IPV4_SUPPORT == ENABLED && IPV6_SUPPORT == ENABLED)
41 #define MAX_CHUNK_COUNT (N(MAX(IPV4_MAX_FRAG_DATAGRAM_SIZE, IPV6_MAX_FRAG_DATAGRAM_SIZE)) + 3)
42 #elif (IPV4_SUPPORT == ENABLED)
43 #define MAX_CHUNK_COUNT (N(IPV4_MAX_FRAG_DATAGRAM_SIZE) + 3)
44 #elif (IPV6_SUPPORT == ENABLED)
45 #define MAX_CHUNK_COUNT (N(IPV6_MAX_FRAG_DATAGRAM_SIZE) + 3)
49 #if (NET_MEM_POOL_SUPPORT == ENABLED)
73 #if (NET_MEM_POOL_SUPPORT == ENABLED)
82 osMemset(memPoolAllocTable, 0,
sizeof(memPoolAllocTable));
102 #if (NET_MEM_POOL_SUPPORT == ENABLED)
113 #if (NET_MEM_POOL_SUPPORT == ENABLED)
124 if(!memPoolAllocTable[i])
127 memPoolAllocTable[i] =
TRUE;
169 #if (NET_MEM_POOL_SUPPORT == ENABLED)
181 memPoolAllocTable[i] =
FALSE;
210 #if (NET_MEM_POOL_SUPPORT == ENABLED)
212 if(currentUsage != NULL)
224 if(currentUsage != NULL)
332 for(i = 0; i < chunkCount && length > 0; i++)
335 chunk = &buffer->
chunk[i];
338 if(length <= chunk->
length)
342 else if(chunk->
size > 0 && i == (chunkCount - 1))
358 while(i < chunkCount)
361 chunk = &buffer->
chunk[i];
382 while(i < buffer->maxChunkCount &&
length > 0)
385 chunk = &buffer->
chunk[i];
430 if(offset < buffer->chunk[i].
length)
470 if(srcOffset < src->chunk[j].
length)
485 while(
length > 0 && i < dest->maxChunkCount && j < src->chunkCount)
493 if(length < dest->chunk[i].length)
535 if(destOffset < dest->chunk[i].
length)
550 if(srcOffset < src->chunk[j].
length)
561 while(
length > 0 && i < dest->chunkCount && j < src->chunkCount)
638 size_t destOffset,
const void *src,
size_t length)
652 if(destOffset < dest->chunk[i].
length)
663 src = (uint8_t *) src +
n;
691 size_t srcOffset,
size_t length)
705 if(srcOffset < src->chunk[i].
length)
716 dest = (uint8_t *) dest +
n;
void memPoolGetStats(uint_t *currentUsage, uint_t *maxUsage, uint_t *size)
Get memory pool usage.
bool_t osCreateMutex(OsMutex *mutex)
Create a mutex object.
void memPoolFree(void *p)
Release a memory block.
size_t netBufferRead(void *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Read data from a multi-part buffer.
Structure describing a buffer that spans multiple chunks.
void * memPoolAlloc(size_t size)
Allocate a memory block.
error_t netBufferConcat(NetBuffer *dest, const NetBuffer *src, size_t srcOffset, size_t length)
Concatenate two multi-part buffers.
__weak_func void * osAllocMem(size_t size)
Allocate a memory block.
#define NET_MEM_POOL_BUFFER_SIZE
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osMemcpy(dest, src, length)
Structure describing a chunk of data.
__weak_func void osFreeMem(void *p)
Release a previously allocated memory block.
#define CHUNKED_BUFFER_HEADER_SIZE
@ ERROR_FAILURE
Generic error code.
error_t memPoolInit(void)
Memory pool initialization.
void netBufferFree(NetBuffer *buffer)
Dispose a multi-part buffer.
error_t netBufferCopy(NetBuffer *dest, size_t destOffset, const NetBuffer *src, size_t srcOffset, size_t length)
Copy data between multi-part buffers.
size_t netBufferGetLength(const NetBuffer *buffer)
Get the actual length of a multi-part buffer.
NetBuffer * netBufferAlloc(size_t length)
Allocate a multi-part buffer.
#define TRACE_WARNING(...)
#define NET_MEM_POOL_BUFFER_COUNT
error_t netBufferAppend(NetBuffer *dest, const void *src, size_t length)
Append data a multi-part buffer.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
error_t netBufferSetLength(NetBuffer *buffer, size_t length)
Adjust the length of a multi-part buffer.
uint_t memPoolCurrentUsage
size_t netBufferWrite(NetBuffer *dest, size_t destOffset, const void *src, size_t length)
Write data to a multi-part buffer.
void * netBufferAt(const NetBuffer *buffer, size_t offset, size_t length)
Returns a pointer to a data segment.
#define osMemset(p, value, length)