#include <stdio.h>
#include <stdlib.h>
struct wasteMem {
char value[1000];
};
wasteMem** table;
int main()
{
int iCount = sizeof(wasteMem*);
table = (wasteMem**)malloc(iCount * 10000000);
// MALLOC MALLOC MALLOC
iCount = 0;
bool bRun = true;
while (bRun) {
table[iCount] = (wasteMem*)malloc(sizeof(wasteMem));
if (table[iCount] == 0) bRun = false;
else iCount++;
};
printf("Allocations MALLOC : %i\r\n", iCount);
iCount--;
bRun = true;
while (bRun) {
free(table[iCount]);
if (iCount == 0) bRun = false;
else iCount--;
};
// NEW NEW NEW
iCount = 0;
bRun = true;
while (bRun) {
table[iCount] = new wasteMem;
if (table[iCount] == 0) bRun = false;
else iCount++;
};
printf("Allocations NEW : %i\r\n", iCount);
iCount--;
bRun = true;
while (bRun) {
delete(table[iCount]);
if (iCount == 0) bRun = false;
else iCount--;
};
free(table);
}