MHEG5  18.9.0
MHEG5 Documentation
Classes | Macros | Typedefs | Functions | Variables
glue_memory.c File Reference

Implement the system dependend memory functions. More...

#include <stdlib.h>
#include <string.h>
#include "stb_os.h"
#include "glue_debug.h"
#include "glue_memory.h"

Go to the source code of this file.

Classes

struct  s_strings_block
 

Macros

#define MallocFunc   STB_MemAlloc
 
#define FreeFunc   STB_MemFree
 
#define MAX_BLK_STRS   0x80 /* 128 memory blocks */
 
#define VTINY_BITS   2
 
#define MIGIT_BITS   3
 
#define SMALL_BITS   4
 
#define MEDUM_BITS   5
 
#define LARGE_BITS   6
 
#define STR_DATA_SIZE(bz)   (MAX_BLK_STRS << bz)
 
#define STR_BLCK_SIZE(bz)   STR_DATA_SIZE(bz) + sizeof(S_STRINGS_BLOCK)
 
#define CONTROL_SIZE   (MAX_BLK_STRS >> 3)
 
#define BlkStrFree(head, bz, data)
 
#define theMemSize   size
 
#define BlkStrAlloc(bk, bz, ln)   BlkStrAlloc(bk, bz)
 

Typedefs

typedef struct s_strings_block S_STRINGS_BLOCK
 

Functions

void MHEG5freeMemFunc (void *what)
 Free some memory allocated by a call to MHEG5getMemFunc. More...
 
void * MHEG5getMemFunc (int size)
 Allocate a block of memory from the free pool. This function should be called using the macro MHEG5getMem. This ensures that the callingFunction parameter is only passed in when MHEG5LOG is defined. More...
 
void STR_Shutdown (void)
 
void STR_TidyUp (void)
 
unsigned char * STR_DataAlloc (unsigned int len)
 
void STR_DataFree (unsigned char *data, unsigned int len)
 
void MHG_DebugMemStats (int line)
 
BOOLEAN MH5GlueMemoryInitialise (void)
 
void MH5GlueMemoryTerminate (void)
 
S_STRING MH5GlueStringCopy (S_STRING source)
 
S_STRING MH5GlueStringConcat (S_STRING src1, S_STRING src2)
 
S_STRING MH5GlueStringAlloc (U32BIT size)
 
S_STRING MH5GlueStringCreate (U32BIT size, U8BIT *data)
 
void MH5GlueStringFree (S_STRING *pStr)
 

Variables

S_STRINGS_BLOCKvtiny_strmem_head = NULL
 
S_STRINGS_BLOCKmigit_strmem_head = NULL
 
S_STRINGS_BLOCKsmall_strmem_head = NULL
 
S_STRINGS_BLOCKmedum_strmem_head = NULL
 
S_STRINGS_BLOCKlarge_strmem_head = NULL
 

Detailed Description

Implement the system dependend memory functions.

Date
05/02/2002
Author
R.Freeman

Definition in file glue_memory.c.

Macro Definition Documentation

#define BlkStrAlloc (   bk,
  bz,
  ln 
)    BlkStrAlloc(bk, bz)

Definition at line 544 of file glue_memory.c.

#define BlkStrFree (   head,
  bz,
  data 
)
Value:
{ S_STRINGS_BLOCK *pBlk = head; \
do { \
unsigned char *blk_data = (unsigned char *)pBlk + sizeof(S_STRINGS_BLOCK); \
if (data >= blk_data \
&& data < blk_data + STR_DATA_SIZE(bz)) \
{ int tmp; \
tmp = (data - blk_data) >> bz; \
pBlk->control[tmp >> 3] &= (U8BIT) ~(1 << (tmp & 7)); \
break; \
} \
pBlk = pBlk->next; \
} while (pBlk != NULL); \
if (pBlk == NULL) { TRACE(TERROR, ("Not freed %x", data)) } \
}
const char * data
Definition: mh5gate.c:56
U8BIT control[CONTROL_SIZE]
Definition: glue_memory.c:71
uint8_t U8BIT
Definition: techtype.h:82
struct s_strings_block * next
Definition: glue_memory.c:70
#define STR_DATA_SIZE(bz)
Definition: glue_memory.c:48
#define TRACE(t, x)
Definition: glue_debug.h:118

Definition at line 52 of file glue_memory.c.

#define CONTROL_SIZE   (MAX_BLK_STRS >> 3)

Definition at line 50 of file glue_memory.c.

#define FreeFunc   STB_MemFree

Definition at line 39 of file glue_memory.c.

#define LARGE_BITS   6

Definition at line 47 of file glue_memory.c.

#define MallocFunc   STB_MemAlloc

Definition at line 38 of file glue_memory.c.

#define MAX_BLK_STRS   0x80 /* 128 memory blocks */

Definition at line 42 of file glue_memory.c.

#define MEDUM_BITS   5

Definition at line 46 of file glue_memory.c.

#define MIGIT_BITS   3

Definition at line 44 of file glue_memory.c.

#define SMALL_BITS   4

Definition at line 45 of file glue_memory.c.

#define STR_BLCK_SIZE (   bz)    STR_DATA_SIZE(bz) + sizeof(S_STRINGS_BLOCK)

Definition at line 49 of file glue_memory.c.

#define STR_DATA_SIZE (   bz)    (MAX_BLK_STRS << bz)

Definition at line 48 of file glue_memory.c.

#define theMemSize   size
#define VTINY_BITS   2

Definition at line 43 of file glue_memory.c.

Typedef Documentation

Function Documentation

BOOLEAN MH5GlueMemoryInitialise ( void  )

Definition at line 807 of file glue_memory.c.

void MH5GlueMemoryTerminate ( void  )

Definition at line 830 of file glue_memory.c.

S_STRING MH5GlueStringAlloc ( U32BIT  size)

Definition at line 924 of file glue_memory.c.

S_STRING MH5GlueStringConcat ( S_STRING  src1,
S_STRING  src2 
)

Definition at line 881 of file glue_memory.c.

S_STRING MH5GlueStringCopy ( S_STRING  source)

Definition at line 847 of file glue_memory.c.

S_STRING MH5GlueStringCreate ( U32BIT  size,
U8BIT data 
)

Definition at line 956 of file glue_memory.c.

void MH5GlueStringFree ( S_STRING pStr)

Definition at line 986 of file glue_memory.c.

void MHEG5freeMemFunc ( void *  what)

Free some memory allocated by a call to MHEG5getMemFunc.

Parameters
whatPointer to allocated memory.
Returns
void

Definition at line 190 of file glue_memory.c.

void* MHEG5getMemFunc ( int  size)

Allocate a block of memory from the free pool. This function should be called using the macro MHEG5getMem. This ensures that the callingFunction parameter is only passed in when MHEG5LOG is defined.

Parameters
callingFunctionPointer to the calling function (only when MHEG5LOG is defined).
sizeSize in bytes of the memory region to allocate.
Returns
Pointer to allocated memory, or NULL if allocation fails.

Definition at line 291 of file glue_memory.c.

void MHG_DebugMemStats ( int  line)

Definition at line 708 of file glue_memory.c.

unsigned char* STR_DataAlloc ( unsigned int  len)

Definition at line 596 of file glue_memory.c.

void STR_DataFree ( unsigned char *  data,
unsigned int  len 
)

Definition at line 668 of file glue_memory.c.

void STR_Shutdown ( void  )

Definition at line 497 of file glue_memory.c.

void STR_TidyUp ( void  )

Definition at line 533 of file glue_memory.c.

Variable Documentation

S_STRINGS_BLOCK* large_strmem_head = NULL

Definition at line 101 of file glue_memory.c.

S_STRINGS_BLOCK* medum_strmem_head = NULL

Definition at line 100 of file glue_memory.c.

S_STRINGS_BLOCK* migit_strmem_head = NULL

Definition at line 98 of file glue_memory.c.

S_STRINGS_BLOCK* small_strmem_head = NULL

Definition at line 99 of file glue_memory.c.

S_STRINGS_BLOCK* vtiny_strmem_head = NULL

Definition at line 97 of file glue_memory.c.