G:/ScriptBasic/source/myalloc.c File Reference

#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include "myalloc.h"

Go to the source code of this file.

Data Structures

struct  _AllocUnit
struct  _MyAlloc

Defines

#define MTHREAD   0
#define LOCK_SEGMENT
#define UNLOCK_SEGMENT
#define LOCK_MALLOC
#define UNLOCK_MALLOC
#define LOCK_STAT
#define UNLOCK_STAT
#define STAT_ADD(NET, BRU)
#define STAT_SUB(NET, BRU)
#define EXTRA_BYTE   (1)

Typedefs

typedef _AllocUnit AllocUnit
typedef _AllocUnitpAllocUnit
typedef _MyAlloc MyAlloc
typedef _MyAllocpMyAlloc

Functions

void * alloc_InitSegment (void *(*maf)(size_t), void(*mrf)(void *))
void alloc_GlobalUseGlobalMutex ()
long alloc_SegmentLimit (void *p, unsigned long NewMaxSize)
void alloc_FreeSegment (void *p)
void alloc_FinishSegment (void *p)
void * alloc_Alloc (size_t n, void *p)
void alloc_Free (void *pMem, void *p)
void alloc_Merge (void *p1, void *p2)
void alloc_MergeAndFinish (void *p1, void *p2)
void alloc_InitStat ()
void alloc_GlobalGetStat (unsigned long *pNetMax, unsigned long *pNetMin, unsigned long *pBruMax, unsigned long *pBruMin, unsigned long *pNetSize, unsigned long *pBruSize)
void alloc_GetStat (void *p, unsigned long *pMax, unsigned long *pMin, unsigned long *pActSize)

Variables

static unsigned long MaxNetSize
static unsigned long MinNetSize
static unsigned long MaxBruSize
static unsigned long MinBruSize
static unsigned long ActNetSize
static unsigned long ActBruSize


Define Documentation

#define EXTRA_BYTE   (1)
 

Referenced by alloc_Alloc().

#define LOCK_MALLOC
 

Definition at line 64 of file myalloc.c.

Referenced by alloc_Alloc(), alloc_FinishSegment(), alloc_Free(), and alloc_FreeSegment().

#define LOCK_SEGMENT
 

Definition at line 62 of file myalloc.c.

Referenced by alloc_Alloc(), alloc_Free(), alloc_FreeSegment(), alloc_GetStat(), and alloc_SegmentLimit().

#define LOCK_STAT
 

Definition at line 66 of file myalloc.c.

Referenced by alloc_GlobalGetStat().

#define MTHREAD   0
 

Definition at line 25 of file myalloc.c.

#define STAT_ADD NET,
BRU   ) 
 

Value:

Definition at line 71 of file myalloc.c.

Referenced by alloc_Alloc(), and alloc_InitSegment().

#define STAT_SUB NET,
BRU   ) 
 

Value:

Definition at line 80 of file myalloc.c.

Referenced by alloc_FinishSegment(), alloc_Free(), and alloc_FreeSegment().

#define UNLOCK_MALLOC
 

Definition at line 65 of file myalloc.c.

Referenced by alloc_Alloc(), alloc_FinishSegment(), alloc_Free(), and alloc_FreeSegment().

#define UNLOCK_SEGMENT
 

Definition at line 63 of file myalloc.c.

Referenced by alloc_Alloc(), alloc_Free(), alloc_FreeSegment(), alloc_GetStat(), and alloc_SegmentLimit().

#define UNLOCK_STAT
 

Definition at line 67 of file myalloc.c.

Referenced by alloc_GlobalGetStat().


Typedef Documentation

typedef struct _AllocUnit AllocUnit
 

typedef struct _MyAlloc MyAlloc
 

typedef struct _AllocUnit * pAllocUnit
 

typedef struct _MyAlloc * pMyAlloc
 


Function Documentation

void* alloc_Alloc size_t  n,
void *  p
 

Definition at line 323 of file myalloc.c.

References _MyAlloc::CurrentSize, EXTRA_BYTE, _MyAlloc::FirstUnit, LOCK_MALLOC, LOCK_SEGMENT, _MyAlloc::MaxNetSize, _MyAlloc::MaxSize, _MyAlloc::memory_allocating_function, NULL, _AllocUnit::prev, _AllocUnit::Size, STAT_ADD, UNLOCK_MALLOC, and UNLOCK_SEGMENT.

Referenced by _ex_PushLabel(), _new_eNODE(), _new_eNODE_l(), _new_SymbolLABEL(), _new_SymbolUF(), _new_SymbolVAR(), AppStart(), build_AllocateStringTable(), build_Build(), build_CreateFTable(), build_CreateVTable(), build_LoadCore(), epreproc(), ex_Global(), ex_init(), ex_IsCommandOPEN(), ex_IsCommandThis(), ex_IsSymbolValidLval(), ex_Local(), ex_LookupGlobalVariable(), ex_LookupLocallyDeclaredGlobalVariable(), ex_LookupLocalVariable(), ex_LookupUserFunction(), ex_PredeclareGlobalLongConst(), ex_Tag(), execute_InitExecute(), execute_InitStructure(), expression_PushNameSpace(), GetExtensionVersion(), handle_GetHandle(), hook_Init(), HttpExtensionProc(), ipreproc_InsertPreprocessor(), ipreproc_LoadInternalPreprocessor(), libscriba_LoadBinaryProgram(), main(), memory_NewVariable(), memory_ReDimArray(), modu_Init(), modu_UnloadAllModules(), modu_UnloadModule(), options_Get(), options_GetR(), options_Reset(), options_Set(), scriba_BuildCode(), scriba_DoLexicalAnalysis(), scriba_DoSyntaxAnalysis(), scriba_GetCacheFileName(), scriba_InheritBinaryProgram(), scriba_InitModuleInterface(), scriba_LoadBinaryProgramWithOffset(), scriba_LoadConfiguration(), scriba_LoadInternalPreprocessor(), scriba_LoadProgramString(), scriba_new(), scriba_NewSbArgs(), scriba_NewSbBytes(), scriba_NewSbData(), scriba_NewSbString(), scriba_PreRun(), scriba_ReadSource(), scriba_RunExternalPreprocessor(), scriba_SetFileName(), and scriba_UseCacheFile().

void alloc_FinishSegment void *  p  ) 
 

Definition at line 297 of file myalloc.c.

References alloc_FreeSegment(), LOCK_MALLOC, _MyAlloc::memory_releasing_function, STAT_SUB, thread_FinishMutex(), and UNLOCK_MALLOC.

Referenced by alloc_MergeAndFinish(), epreproc(), ex_free(), HttpExtensionProc(), ipreproc_DeletePreprocessor(), ipreproc_PurgePreprocessorMemory(), main(), modu_Init(), scriba_destroy(), scriba_new(), scriba_PurgeBuilderMemory(), scriba_PurgeExecuteMemory(), scriba_PurgeLexerMemory(), scriba_PurgeReaderMemory(), and TerminateExtension().

void alloc_Free void *  pMem,
void *  p
 

Definition at line 397 of file myalloc.c.

References _MyAlloc::CurrentSize, _MyAlloc::FirstUnit, LOCK_MALLOC, LOCK_SEGMENT, _MyAlloc::memory_releasing_function, _MyAlloc::MinNetSize, _AllocUnit::next, NULL, printf(), STAT_SUB, UNLOCK_MALLOC, and UNLOCK_SEGMENT.

Referenced by AppStart(), ex_CleanNameSpaceStack(), ex_Global(), ex_IsCommandThis(), ex_IsSymbolValidLval(), ex_Local(), ex_LookupGlobalVariable(), ex_LookupLocallyDeclaredGlobalVariable(), ex_LookupLocalVariable(), ex_LookupUserFunction(), ex_PredeclareGlobalLongConst(), ex_Tag(), expression_PopNameSpace(), expression_PushNameSpace(), GetExtensionVersion(), handle_DestroyHandleArray(), handle_GetHandle(), HttpExtensionProc(), ipreproc_DeletePreprocessor(), main(), memory_NewVariable(), memory_ReDimArray(), memory_ReleaseVariable(), modu_Init(), options_Get(), options_GetR(), options_Reset(), options_Set(), scriba_CallArgEx(), scriba_DestroySbArgs(), scriba_DestroySbData(), scriba_DoLexicalAnalysis(), scriba_GetCacheFileName(), scriba_LoadConfiguration(), scriba_LoadProgramString(), scriba_NewSbArgs(), scriba_NewSbBytes(), scriba_NewSbString(), scriba_PurgeBuilderMemory(), scriba_PurgeExecuteMemory(), scriba_PurgeLexerMemory(), scriba_PurgePreprocessorMemory(), scriba_PurgeReaderMemory(), scriba_PurgeSyntaxerMemory(), scriba_ReadSource(), scriba_RunExternalPreprocessor(), scriba_SetFileName(), scriba_UndefSbData(), and scriba_UseCacheFile().

void alloc_FreeSegment void *  p  ) 
 

Definition at line 260 of file myalloc.c.

References _MyAlloc::CurrentSize, _MyAlloc::FirstUnit, LOCK_MALLOC, LOCK_SEGMENT, _MyAlloc::memory_releasing_function, _MyAlloc::MinNetSize, _AllocUnit::next, NULL, _AllocUnit::Size, STAT_SUB, UNLOCK_MALLOC, and UNLOCK_SEGMENT.

Referenced by alloc_FinishSegment(), and modu_Init().

void alloc_GetStat void *  p,
unsigned long *  pMax,
unsigned long *  pMin,
unsigned long *  pActSize
 

Definition at line 591 of file myalloc.c.

References _MyAlloc::CurrentSize, LOCK_SEGMENT, _MyAlloc::MaxNetSize, _MyAlloc::MinNetSize, and UNLOCK_SEGMENT.

void alloc_GlobalGetStat unsigned long *  pNetMax,
unsigned long *  pNetMin,
unsigned long *  pBruMax,
unsigned long *  pBruMin,
unsigned long *  pNetSize,
unsigned long *  pBruSize
 

Definition at line 553 of file myalloc.c.

References ActBruSize, ActNetSize, LOCK_STAT, MaxBruSize, MaxNetSize, MinBruSize, MinNetSize, and UNLOCK_STAT.

void alloc_GlobalUseGlobalMutex  ) 
 

Definition at line 199 of file myalloc.c.

References thread_InitMutex().

void* alloc_InitSegment void *(*)(size_t)  maf,
void(*)(void *)  mrf
 

Definition at line 146 of file myalloc.c.

References _MyAlloc::CurrentSize, _MyAlloc::FirstUnit, _MyAlloc::MaxNetSize, _MyAlloc::MaxSize, _MyAlloc::memory_allocating_function, _MyAlloc::memory_releasing_function, _MyAlloc::MinNetSize, NULL, STAT_ADD, thread_InitMutex(), thread_LockMutex(), and thread_UnlockMutex().

Referenced by AppStart(), build_Build(), build_LoadCodeWithOffset(), epreproc(), ex_init(), ex_IsCommandThis(), execute_InitStructure(), GetExtensionVersion(), HttpExtensionProc(), ipreproc_LoadInternalPreprocessor(), libscriba_LoadBinaryProgram(), main(), memory_InitStructure(), modu_Init(), scriba_DoLexicalAnalysis(), scriba_InitModuleInterface(), scriba_LoadInternalPreprocessor(), scriba_LoadProgramString(), scriba_new(), and scriba_ReadSource().

void alloc_InitStat  ) 
 

Definition at line 525 of file myalloc.c.

References ActBruSize, ActNetSize, MaxBruSize, MaxNetSize, MinBruSize, MinNetSize, and thread_InitMutex().

void alloc_Merge void *  p1,
void *  p2
 

Definition at line 454 of file myalloc.c.

References _MyAlloc::CurrentSize, _MyAlloc::FirstUnit, next, NULL, p, _AllocUnit::prev, q, thread_LockMutex(), and thread_UnlockMutex().

Referenced by alloc_MergeAndFinish(), and HttpExtensionProc().

void alloc_MergeAndFinish void *  p1,
void *  p2
 

Definition at line 506 of file myalloc.c.

References alloc_FinishSegment(), and alloc_Merge().

long alloc_SegmentLimit void *  p,
unsigned long  NewMaxSize
 

Definition at line 235 of file myalloc.c.

References LOCK_SEGMENT, _MyAlloc::MaxSize, and UNLOCK_SEGMENT.

Referenced by execute_InitStructure(), main(), and modu_Init().


Variable Documentation

unsigned long ActBruSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().

unsigned long ActNetSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().

unsigned long MaxBruSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().

unsigned long MaxNetSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().

unsigned long MinBruSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().

unsigned long MinNetSize [static]
 

Definition at line 39 of file myalloc.c.

Referenced by alloc_GlobalGetStat(), and alloc_InitStat().


Generated on Sun Mar 12 23:56:37 2006 for ScriptBasic by  doxygen 1.4.6-NO