Don't always zero memory in malloc(). This saves around 2us on a

full-length PKB allocation.
This commit is contained in:
Michael Brown
2007-01-18 12:54:18 +00:00
parent 06630a3036
commit 35776f481c
2 changed files with 23 additions and 6 deletions

View File

@@ -134,8 +134,6 @@ void * alloc_memblock ( size_t size, size_t align ) {
*/
if ( pre_size < MIN_MEMBLOCK_SIZE )
list_del ( &pre->list );
/* Zero allocated memory, for calloc() */
memset ( block, 0, size );
DBG ( "Allocated [%p,%p)\n", block,
( ( ( void * ) block ) + size ) );
return block;
@@ -297,6 +295,23 @@ void free ( void *ptr ) {
realloc ( ptr, 0 );
}
/**
* Allocate cleared memory
*
* @v size Requested size
* @ret ptr Allocated memory
*
* Allocate memory as per malloc(), and zero it.
*/
void * _calloc ( size_t size ) {
void *data;
data = malloc ( size );
if ( data )
memset ( data, 0, size );
return data;
}
/**
* Add memory to allocation pool
*