- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
volatile void* AllocatedMemory;
int AllocateMemoryThread(const int size)
{
char buffer[size];
AllocatedMemory=(void*)buffer;
AllocatingDone.Signal();
Sleep(INFINITY);
return 0;
};
...
void* MAlloc(const int size)
{
CriticalSection.Lock();
if( !CreateThread(AllocateMemoryThread,true,size,0) )
return NULL;
AllocatingDone.Wait();
const void* AllocatedBuffer=AllocatedMemory;
CriticalSection.UnLock();
return AllocatedBuffer;
};
Follow us!