|
Lhogho
0.0.027
|
Defines | |
| #define | FORMAT_MEM TEXT("{Mem@%0x}") |
| #define | MEMORY(x) ((x)->unode.v[2]) |
| #define | ATOMS(x) ((x)->unode.a[3]) |
| #define | IS_MEM(x) (ID(x)==MEM_ID) |
| #define | MEM_STRUCT_SIZE 0 |
| action: calculate struct size | |
| #define | MEM_STRUCT_PACK 1 |
| action: pack atoms to struct | |
| #define | MEM_STRUCT_UNPACK 2 |
| action: unpack struct to atoms | |
Functions | |
| atom_t | new_mem (uint_t size) |
| creates a new mem atom | |
| void | delete_mem (atom_t a) |
| deletes mem atom | |
| void | dump_mem (atom_t a, int level) |
| dumps mem atom | |
| #define FORMAT_MEM TEXT("{Mem@%0x}") |
| #define MEMORY | ( | x | ) | ((x)->unode.v[2]) |
| #define ATOMS | ( | x | ) | ((x)->unode.a[3]) |
| #define MEM_STRUCT_SIZE 0 |
| #define MEM_STRUCT_PACK 1 |
| #define MEM_STRUCT_UNPACK 2 |
| size | size of memory to allocate |
Creates a memory atom with reference count 1.
{
atom_t a = take_from_pool( &data_pool );
REF(a) = 1;
ID(a) = MEM_ID;
MEMORY(a) = XALLOC( (size_t)size );
ATOMS(a) = empty_list;
#ifdef SAFEMODE
assert( MEMORY(a) );
#endif //SAFEMODE
#ifdef DEBUG_ATOM
printf("<ATOM> [%08x] mem={%d bytes}\n",(int)a,size);
#endif //DEBUG_ATOM
#ifdef ADVANCED
stats[ID(a)].allocs++;
if( stats[ID(a)].max<(stats[ID(a)].allocs-stats[ID(a)].deallocs) )
stats[ID(a)].max=(stats[ID(a)].allocs-stats[ID(a)].deallocs);
stats_free--;
#endif //ADVANCED
#ifdef DEBUG_RUNTIME_ATOMS
if( running_compiled_code )
{
outter( TEXT("<RUNTIME> new "), -1 );
dump_atom_address( a );
dump_atom( a, 1 );
outter( TEXT("\n"), -1 );
}
#endif
#ifdef DEBUG_COMPILETIME_ATOMS
if( compiling_code )
{
outter( TEXT("<COMPILETIME> new "), -1 );
dump_atom_address( a );
dump_atom( a, 1 );
outter( TEXT("\n"), -1 );
}
#endif
return a;
}
| void delete_mem | ( | atom_t | a | ) |
| a | atom to dump |
| level | dump level |
Dumps mem through the current outter function.
{
#define DUMP_BUF_SIZE 128
char_t buf[DUMP_BUF_SIZE];
int n;
n = SPRINTF( buf, DUMP_BUF_SIZE, FORMAT_MEM, (int)MEMORY(a) );
outter( buf, n );
#undef DUMP_BUF_SIZE
}