/* Code active when included from pre-boot environment: */
/* * Some architectures want to ensure there is no local data in their * pre-boot environment, so that data can arbitrarily relocated (via * GOT references). This is achieved by defining STATIC_RW_DATA to * be null.
*/ #ifndef STATIC_RW_DATA #define STATIC_RW_DATA static #endif
/* * When an architecture needs to share the malloc()/free() implementation * between compilation units, it needs to have non-local visibility.
*/ #ifndef MALLOC_VISIBLE #define MALLOC_VISIBLE static #endif
/* A trivial malloc implementation, adapted from * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994
*/
STATIC_RW_DATA unsignedlong malloc_ptr;
STATIC_RW_DATA int malloc_count;
MALLOC_VISIBLE void *malloc(int size)
{ void *p;
if (size < 0) return NULL; if (!malloc_ptr)
malloc_ptr = free_mem_ptr;
malloc_ptr = (malloc_ptr + 7) & ~7; /* Align */
p = (void *)malloc_ptr;
malloc_ptr += size;
if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr) return NULL;
/* Use defines rather than static inline in order to avoid spurious * warnings when not needed (indeed large_malloc / large_free are not
* needed by inflate */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.