Dallas Semiconductor DS80C400 C Libraries Home Page

Main Page   Data Structures   File List   Data Fields   Globals  

rom400_mem.h File Reference


Detailed Description

Memory management functions in the DS80C400 ROM.

This library contains functions for allocating and de-allocating blocks of memory through the ROM's memory manager.

For detailed information on the DS80C400 please see the High-Speed Microcontroller User's Guide: DS80C400 Supplement.

The methods in this library are all multi-process safe. That is, a function can be called by more than one process at the same time and its parameters won't be destroyed.

Go to the source code of this file.

Defines

#define ROM400_MEM_VERSION   6

Functions

void * mem_malloc (unsigned int size)
 Requests a block of memory to be allocated.

void * mem_mallocdirty (unsigned int size)
 Requests a block of memory to be allocated.

unsigned char mem_free (void *ptr)
 De-allocates a block of memory.

unsigned long mem_getfreeram (void)
 Returns the amount of memory available for allocation.

unsigned int mem_sizeof (void *ptr)
 Gets the size of an allocated block of memory.

unsigned int mem_version (void)
 Returns the version number of this memory management library.

void mem_coalesce (void)
 Join adjacent chunks of freed memory.


Define Documentation

#define ROM400_MEM_VERSION   6
 

Version number associated with this header file. Should be the same as the version number returned by the mem_version function.

See also:
mem_version


Function Documentation

void mem_coalesce void   
 

Join adjacent chunks of freed memory.

When the memory manager frees allocated memory, it makes no attempt to rejoin adjacent pieces of memory, Therefore, the memory becomes fragmented over time unless the allocation calls are very careful. This function will join adjacent pieces of memory and make the larger piece available for allocation.

unsigned char mem_free void *    ptr
 

De-allocates a block of memory.

Deallocates a block of memory that was previously allocated by calling mem_malloc or mem_mallocdirty, making this block available for re-allocation. Use the function mem_getfreeram to determine how much memory is available for allocation.

This is a redirected function. The ROM includes a default memory manager implementation. See the DS80C400 User's Guide for information on replacing the default memory manager with your own memory manager.

Parameters:
ptr pointer to the beginning of the previously allocated memory
Returns:
0 for success, non-zero for failure
See also:
mem_malloc

mem_mallocdirty

mem_getfreeram

mem_sizeof

unsigned long mem_getfreeram void   
 

Returns the amount of memory available for allocation.

Returns the total amount of memory available for allocation. Memory is allocated in increments of 32 bytes. Due to fragmentation, large memory allocations may not be possible.

Note that the size returned by this function includes the memory manager overhead for this particular block. For example, if you request 512 bytes in a call to mem_malloc, this function will report the amount 512 plus overhead size, rounded up to the next 32-byte block (thus returning 544).

This is a redirected function. The ROM includes a default memory manager implementation. See the DS80C400 User's Guide for information on replacing the default memory manager with your own memory manager.

See also:
mem_sizeof
Returns:
The amount of memory available for allocation from the memory manager.

void* mem_malloc unsigned int    size
 

Requests a block of memory to be allocated.

Tries to allocate a block of memory of the requested size. The data allocated is filled with 0's. To request non-cleared memory (and save the extra time) use mem_mallocdirty. To de-allocate the memory block, use mem_free.

This is a redirected function. The ROM includes a default memory manager implementation. See the DS80C400 User's Guide for information on replacing the default memory manager with your own memory manager.

Parameters:
size amount of data requested for allocation
Returns:
pointer to the newly allocated memory, or NULL (0) if the operation failed
See also:
mem_mallocdirty

mem_free

mem_sizeof

void* mem_mallocdirty unsigned int    size
 

Requests a block of memory to be allocated.

Tries to allocate a block of memory of the requested size. The data allocated is NOT filled with 0's, and is likely to be filled with unpredictable values. To request cleared memory, use mem_malloc. To de-allocate the memory block, use mem_free.

This is a redirected function. The ROM includes a default memory manager implementation. See the DS80C400 User's Guide for information on replacing the default memory manager with your own memory manager.

Parameters:
size amount of data requested for allocation
Returns:
pointer to the newly allocated memory, or NULL (0) if the operation failed
See also:
mem_malloc

mem_free

mem_sizeof

unsigned int mem_sizeof void *    ptr
 

Gets the size of an allocated block of memory.

Returns the size of a block of memory that was allocated by the ROM's default memory manager. If the input pointer is not a valid pointer that was created by an earlier call to mem_malloc or #mem_dirtymalloc, the value returned has no meaning.

This is NOT a redirected function, and only functions if the ROM's default memory manager is used.

Parameters:
ptr pointer to the beginning of the previously allocated memory
Returns:
size of the memory allocated for a valid input pointer
See also:
mem_malloc

mem_mallocdirty

mem_getfreeram

unsigned int mem_version void   
 

Returns the version number of this memory management library.

Returns:
Version number of this memory management library.


Copyright 2004 Dallas Semiconductor, Inc.. Documentation generated by Doxygen.