1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include <stdlib.h>
#include <stdio.h>
#ifdef WIN32
#include <windows.h>
#define sleep(s) Sleep ((s)*1000)
#else
#include <unistd.h> /* enfin, je crois */
#endif
int main (void)
{
char **tab;
int i;
sleep (5);
printf ("Allocation...\n");
tab = malloc (200000 * sizeof *tab);
for (i = 0; i < 200000; i++)
{
tab[i] = malloc (64 * sizeof *tab[i]);
}
printf ("Ok\n");
sleep (7);
printf ("Desallocation...\n");
for (i = 0; i < 200000; i++)
{
free (tab[i]);
}
free (tab);
printf ("Ok\n");
sleep (20);
return 1;
} |
Partager