Home | Contact | About | Search

Embedded Networking Consulting Login
emenu
emenu OS API emenu Profiler emenu MemTool emenu PCI emenu Reference emenu Links emenu
emenu emenu emenu emenu emenu emenu


Memory Allocation


memFixedCreateHeap ( )
Name: memFixedCreateHeap ( ) - create fix sized memory pool
Synopsis:
MEM_HANDLE memFixedCreateHeap
(
  u32 u32Num,      /* number of blocks to create */
  u32 u32BlockSize /* size of each block in bytes */
)
Description: Creates a pool of u32Num memory blocks that are each u32BlockSize bytes in size. This function is much faster than any traditional malloc() function and cannot fragment memory. This function should be called on startup only.
Include: memory.h
Returns: The MEM_HANDLE of the newly created fixed sized heap. Note that this function will not return if the fixed size heap cannot be created, instead the system will halt (during development) or reboot (if in the field) so there are no illegal values that can be returned.
See Also: memFixedDestroyHeap, memFixedAlloc, memFixedFree

memFixedDestroyHeap ( )
Name: memFixedDestroyHeap ( ) - destroy fix sized memory pool
Synopsis:
void memFixedDestroyHeap
(
  MEM_HANDLE memHandle /* fixed memory pool to destroy */
)
Description: Destroys a memory pool. This function should not be called if any blocks in the pool are currently allocated, to do so will produce undefined behavior.
Include: memory.h
Returns: nothing
See Also: memFixedCreateHeap, memFixedAlloc, memFixedFree

memFixedAlloc ( )
Name: memFixedAlloc ( ) - allocates from a fixed heap
Synopsis:
void * memFixedAlloc
(
  MEM_HANDLE memHandle,            /* pool to allocate from */
  u32        u32MillisecondsToWait /* timeout in ms */
)
Description: Allocates from a fixed memory pool. If memory is not immediately available the function will block for u32MillisecondsToWait milliseconds before NULL is returned. If a nonblocking allocate is attempted u32MillisecondsToWait should be set to NO_WAIT. WAIT_FOREVER can be used to block forever. Memory allocated by this function must be freed by memFixedFree.
Include: memory.h
Returns: a pointer to the newly allocated memory or NULL if there was no memory available. Note that this function will never return NULL if u32MillisecondsToWait was set to WAIT_FOREVER.
See Also: memFixedFree

memFixedFree ( )
Name: memFixedFree ( ) - frees memory allocated from a fixed heap
Synopsis:
void memFixedFree
(
  void *vPtr /* memory to free */
)
Description: Frees memory allocated by the function memFixedAlloc.
Include: memory.h
Returns: nothing
See Also: memFixedAlloc

memAlloc ( )
Name: memAlloc ( ) - allocates a variable amount of memory
Synopsis:
void * memAlloc
(
  u32 u32Bytes /* number of bytes to allocate */
)
Description: Allocates from a general memory pool. Care should be taken in using this function since memory fragmentation can occur if memory is dynamically allocated and freed during runtime. Memory allocated by this function must be freed by memFree.
Include: memory.h
Returns: a pointer to the newly allocated memory or NULL if there was no memory available.
See Also: memFree

memFree ( )
Name: memFixedFree ( ) - frees memory allocated from a general heap
Synopsis:
void memFree
(
  void *vPtr /* memory to free */
)
Description: Frees memory allocated by the function memAlloc.
Include: memory.h
Returns: nothing
See Also: memAlloc


 


© 2001-2002 Navosha, Inc.