1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

- Moved the memory initialization and cleanup functions into the

malloc/free code itself and updated the alloca code to do its
  own data management.

- Finally optimized the alloca() memory cleanup code.


git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14784 87f5fb63-7c3d-0410-a384-fd976d0f7a62
This commit is contained in:
Olaf Barthel
2004-12-24 11:46:12 +00:00
parent 3c9f119046
commit 73e6ccc14e
12 changed files with 189 additions and 148 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: stdlib_malloc.c,v 1.1.1.1 2004-07-26 16:31:59 obarthel Exp $
* $Id: stdlib_malloc.c,v 1.2 2004-12-24 11:46:12 obarthel Exp $
*
* :ts=4
*
@ -54,10 +54,19 @@ unsigned long __current_memory_allocated;
unsigned long __maximum_num_memory_chunks_allocated;
unsigned long __current_num_memory_chunks_allocated;
#if defined(__USE_MEM_TREES)
struct MemoryTree __memory_tree;
#endif /* __USE_MEM_TREES */
#endif /* __MEM_DEBUG */
/****************************************************************************/
APTR __memory_pool;
struct MinList __memory_list;
/****************************************************************************/
size_t
__get_allocation_size(size_t size)
{
@ -203,8 +212,7 @@ __malloc(size_t size,const char * file,int line)
void * result = NULL;
/* Try to get rid of now unused memory. */
/*if(NOT IsListEmpty((struct List *)&__alloca_memory_list))
__alloca_cleanup(file,line);*/
/*__alloca_cleanup(file,line);*/
#ifdef __MEM_DEBUG
{
@ -250,3 +258,24 @@ malloc(size_t size)
return(result);
}
/****************************************************************************/
void
__memory_init(void)
{
ENTER();
#if defined(__USE_MEM_TREES) && defined(__MEM_DEBUG)
{
__initialize_red_black_tree(&__memory_tree);
}
#endif /* __USE_MEM_TREES && __MEM_DEBUG */
NewList((struct List *)&__memory_list);
if(((struct Library *)SysBase)->lib_Version >= 39)
__memory_pool = CreatePool(MEMF_ANY,(ULONG)__default_pool_size,(ULONG)__default_puddle_size);
LEAVE();
}