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
|
#include <assert.h>
#include <string.h>
#define PERR(e)\
do\
{\
if (e)\
{\
printf ("ERR %d at %s:%d\n", e, __FILE__, __LINE__); \
}\
}\
while (0)
int main (void)
{
char s[20];
p_mesMalloc *p = ajoutNouveauMalloc (s, sizeof s);
if (p != NULL)
{
printf ("Taille allouee = %lu\n",
(unsigned long) calculTailleMemoireAllouee ());
assert (p->ptr != NULL);
strcpy (p->ptr, "Hello world");
printf ("%s\n", (char *) p->ptr);
{
int err = suppressionMalloc (p);
PERR (err);
}
}
return 0;
} |