Files
rtems/cpukit/libcsupport/src/malloc.c
Sebastian Huber 9d1f394345 malloc: Add _Malloc_System_state()
Replace malloc_is_system_state_OK() with _Malloc_System_state() to allow
early allocations, e.g. in bsp_start().  Here the _Thread_Executing is
NULL, thus an _API_Mutex_Lock() would lead to a NULL pointer access.

Move malloc() support code to general case
rtems_heap_allocate_aligned_with_boundary().  Use
rtems_heap_allocate_aligned_with_boundary() to avoid duplicated code.
2016-02-25 11:35:54 +01:00

49 lines
792 B
C

/**
* @file
*
* @brief RTEMS Malloc Family Implementation
* @ingroup libcsupport
*/
/*
* COPYRIGHT (c) 1989-2007.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.org/license/LICENSE.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef RTEMS_NEWLIB
#include <stdlib.h>
#include <errno.h>
#include "malloc_p.h"
void *malloc(
size_t size
)
{
void *return_this;
/*
* Validate the parameters
*/
if ( !size )
return (void *) 0;
return_this = rtems_heap_allocate_aligned_with_boundary( size, 0, 0 );
if ( !return_this ) {
errno = ENOMEM;
return (void *) 0;
}
return return_this;
}
#endif