struct MemHeader *mh;
struct MemChunk *mc;
APTR block1;
APTR block2;
/* Get the MemHeader needed to keep track of our new block */
mh = (struct MemHeader *)
AllocMem(sizeof(struct MemHeader), MEMF_CLEAR );
if( mh == NULL )
/* Get the actual block the above MemHeader will manage */
mc = (struct MemChunk *)
AllocMem( BLOCKSIZE, MEMF_ANY );
if( mc == NULL )
{
FreeMem( mh, sizeof(struct MemHeader) );
exit(10);
}
mh->mh_Node.ln_Type = NT_MEMORY;
mh->mh_Node.ln_Name = "myname";
mh->mh_First = mc;
mh->mh_Lower = (APTR) mc;
mh->mh_Upper = (APTR) ( BLOCKSIZE + (BYTE *)mc );
mh->mh_Free = BLOCKSIZE;
/* Set up first chunk in the freelist */
mc->mc_Next = NULL;
mc->mc_Bytes = BLOCKSIZE;
block1 = (APTR) Allocate( mh, 20 );
block2 = (APTR) Allocate( mh, 314 );
printf("mh=$%lx mc=$%lx\n",mh,mc);
printf("Block1=$%lx, Block2=$%lx\n",block1,block2);
FreeMem( mh, sizeof(struct MemHeader) );
FreeMem( mc, BLOCKSIZE );