MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
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"

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_BLOCK * vtiny_strmem_head = NULL
 
S_STRINGS_BLOCK * migit_strmem_head = NULL
 
S_STRINGS_BLOCK * small_strmem_head = NULL
 
S_STRINGS_BLOCK * medum_strmem_head = NULL
 
S_STRINGS_BLOCK * large_strmem_head = NULL
 

Detailed Description

Implement the system dependend memory functions.

Date
05/02/2002
Author
R.Freeman

Macro Definition Documentation

#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)) } \
}
#define TRACE(t, x)
Definition: glue_debug.h:118

Function Documentation

void MHEG5freeMemFunc ( void *  what)

Free some memory allocated by a call to MHEG5getMemFunc.

Parameters
whatPointer to allocated memory.
Returns
void
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.