malloc.c File Reference

Simple kernel memory allocator. More...

#include "malloc.h"
#include "sys.h"
#include "int.h"
#include "debug.h"
#include "io.h"

Functions

void * mem_end_detect (void *s)
 Function to detect the amount of memory.
void * alloc_mem_block (unsigned size)
 Allocate a new free memory block.
void free_mem_block (void *px)
 Mark the block as free.
void init_memory ()
 Initialize the memory block structures.
void * malloc (tsize size)
 Thread safe memory allocation.
void free (void *ptr)
 Thread safe memory release.
void memory_leak_error ()
 Call panic when memory leak error.


Detailed Description

Simple kernel memory allocator.


Function Documentation

void* alloc_mem_block ( unsigned  size  ) 

Allocate a new free memory block.

Parameters:
size - new memory block size
Returns:
pointer to new block or 0 if not enought memory
!!! This routine is NOT thread safe.

void free ( void *  ptr  ) 

Thread safe memory release.

Parameters:
ptr - pointer to memory block
This function only improve free_mem_block() to be thread save

void free_mem_block ( void *  px  ) 

Mark the block as free.

Parameters:
px - pointer to memory block
!!! This routine is NOT thread safe.

void* malloc ( tsize  size  ) 

Thread safe memory allocation.

Parameters:
size - new memory block size
This function only improve alloc_mem_block() to be thread save

void* mem_end_detect ( void *  s  ) 

Function to detect the amount of memory.

Parameters:
s - pointer to starting address
Returns:
amount of memory
Starts at end of the kernel image and attempts to write a value every 1024 bytes. When it fails to read back the same value as was written, we consider that to be the last address we are able to write to.


Generated on Wed Nov 15 17:25:43 2006 for Kalisto by  doxygen 1.4.7