void * operator new( unsigned int iSize )
{
static unsigned char aMemPool[10000];
static unsigned iUsed = 0;
iUsed += iSize;
if( iUsed > 10000 )
{
return 0;
}
return &aMemPool[iUsed-iSize];
}
void MEM_UnitTest()
{
for( int i = 0; i < 100000; i++ )
{
int *piTest = new int;
*piTest = i;
delete piTest;
}
}
emin3m
0
Newbie Poster
Recommended Answers
Jump to PostThe function new returns a pointer to the end of the memory block, not the beginning. I think it would work if written like this:
void * operator new( unsigned int iSize ) { static unsigned char aMemPool[10000]; static unsigned iUsed = 0; if( iSize == 0 …
All 3 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Salem
5,138
Posting Sage
vijayan121
1,152
Posting Virtuoso
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.