Main Page

# Memory Management

Every program ever written has had to deal with memory management. Simulavr is no exception. For portability and to potentially aid in memory debugging, simulavr supplies it's own functions and macros for handling the allocation and releasing of memory resources.

For memory which could be used by many differing parts of the simulator, an object referencing system has been implemented (see Objects).

## Memory Functions

The following functions provide wrappers for all library functions that return memory which simulavr must manage.

- avr_malloc()
- avr_malloc0()
- avr_realloc()
- avr_strdup()
- avr_free()

All functions which return allocated memory will only return if the allocation was successful. If the allocation failed, an error message is issued and the program is aborted. Thus, the developer does not need write any code to check the returned value.

## Memory Macros

The following C-preprocessor macro definitions are provided for convenience and should be used instead of the underlying functions. These macros relieve the programmer from having to perform manual type-casting thus making the code easier to read.

- avr_new()
- avr_new0()
- avr_renew()

Automatically generated by Doxygen 1.7.2 on Wed Feb 22 2012.