Embedded/common/src/b_BasicEm/Context.c
/* adds a dynamic memory segment to memory table of context
 * Upon destruction of the context object any residual will be freed automatically
 */
adds a dynamic memory segment to memory table of context
Upon destruction of the context object any residual will be freed automatically
adds a dynamic memory segment to memory table of context Upon destruction of the context object any residual will be freed automatically
void bbs_Context_addDynamicSeg(	struct bbs_Context* cpA,
								bbs_mallocFPtr mallocFPtrA,	
								bbs_freeFPtr freeFPtrA,     
								flag sharedA,    
								uint32 idA )     
{
	struct bbs_DynMemManager memManagerL;
	struct bbs_MemSeg memSegL;
	bbs_DEF_fNameL( "void bbs_Context_addDynamicSeg(....)" )
	if( cpA->dynMemManagerArrSizeE == bbs_CONTEXT_MAX_MEM_MANAGERS )
	{
		bbs_ERROR1( "%s:\nMemory Manager Table is full! Increase bbs_CONTEXT_MAX_MEM_MANAGERS", fNameL );
		return;
	}
	if( sharedA && cpA->memTblE.ssSizeE == bbs_MAX_MEM_SEGS )
	{
		bbs_ERROR1( "%s:\nShared Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
		return;
	}
	if( sharedA && cpA->memTblE.esSizeE == bbs_MAX_MEM_SEGS )
	{
		bbs_ERROR1( "%s:\nExclusive Memory Table is full! Increase bbs_MAX_MEM_SEGS", fNameL );
		return;
	}
	bbs_DynMemManager_init( cpA, &memManagerL );
	memManagerL.mallocFPtrE = mallocFPtrA;
	memManagerL.freeFPtrE = freeFPtrA;
	memManagerL.memPtrE = NULL;
	cpA->dynMemManagerArrE[ cpA->dynMemManagerArrSizeE++ ] = memManagerL;
	bbs_MemSeg_init( cpA, &memSegL );
	memSegL.memPtrE = NULL;
	memSegL.sizeE = 0;
	memSegL.allocIndexE = 0;
	memSegL.sharedE = sharedA;
	memSegL.idE = idA;
	memSegL.dynMemManagerPtrE = &cpA->dynMemManagerArrE[ cpA->dynMemManagerArrSizeE - 1 ];
	if( sharedA )
	{
		cpA->memTblE.ssArrE[ cpA->memTblE.ssSizeE++ ] = memSegL;
	}
	else
	{
		cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ] = memSegL;
		cpA->memTblE.espArrE[ cpA->memTblE.esSizeE ] = &cpA->memTblE.esArrE[ cpA->memTblE.esSizeE ];
		cpA->memTblE.esSizeE++;
	}
}
void bbs_Context_addDynamicSeg ( struct bbs_Context * cpA , bbs_mallocFPtr mallocFPtrA , bbs_freeFPtr freeFPtrA , flag sharedA , uint32 idA ) { struct bbs_DynMemManager memManagerL ; struct bbs_MemSeg memSegL ; bbs_DEF_fNameL ( " " ) if ( cpA -> dynMemManagerArrSizeE == bbs_CONTEXT_MAX_MEM_MANAGERS ) { bbs_ERROR1 ( " \n " , fNameL ) ; return ; } if ( sharedA && cpA -> memTblE . ssSizeE == bbs_MAX_MEM_SEGS ) { bbs_ERROR1 ( " \n " , fNameL ) ; return ; } if ( sharedA && cpA -> memTblE . esSizeE == bbs_MAX_MEM_SEGS ) { bbs_ERROR1 ( " \n " , fNameL ) ; return ; } bbs_DynMemManager_init ( cpA , & memManagerL ) ; memManagerL . mallocFPtrE = mallocFPtrA ; memManagerL . freeFPtrE = freeFPtrA ; memManagerL . memPtrE = NULL ; cpA -> dynMemManagerArrE [ cpA -> dynMemManagerArrSizeE ++ ] = memManagerL ; bbs_MemSeg_init ( cpA , & memSegL ) ; memSegL . memPtrE = NULL ; memSegL . sizeE = 0 ; memSegL . allocIndexE = 0 ; memSegL . sharedE = sharedA ; memSegL . idE = idA ; memSegL . dynMemManagerPtrE = & cpA -> dynMemManagerArrE [ cpA -> dynMemManagerArrSizeE - 1 ] ; if ( sharedA ) { cpA -> memTblE . ssArrE [ cpA -> memTblE . ssSizeE ++ ] = memSegL ; } else { cpA -> memTblE . esArrE [ cpA -> memTblE . esSizeE ] = memSegL ; cpA -> memTblE . espArrE [ cpA -> memTblE . esSizeE ] = & cpA -> memTblE . esArrE [ cpA -> memTblE . esSizeE ] ; cpA -> memTblE . esSizeE ++ ; } }
adds a dynamic memory segment to memory table of context
 Upon destruction of the context object any residual will be freed automatically
adds a dynamic memory segment to memory table of context Upon destruction of the context object any residual will be freed automatically
/* function pointer to external mem alloc function (s. comment of type declaration)*/ /* function pointer to external mem free function */ /* Indicates that this segment is to be shared among multiple objects */ /* ID of segment, id=0: unspecified */ /* checks */