Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

test.c

Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include "rtl_malloc.h"
00003 
00004 #define KiloByte  1024
00005 #define POOL_SIZE 1024
00006 
00007 
00008 // Pool size is in Kbytes.
00009 char pool[POOL_SIZE*KiloByte];
00010 
00011 
00012 main(){
00013     int *ptr[100];
00014     int i, free_mem;
00015 
00016     free_mem = init_memory_pool(POOL_SIZE, 5, pool);
00017     printf("Total free memory= %d\n", free_mem);
00018 
00019     // default malloc and free use this buffer.
00020     associate_buffer(pool);
00021 
00022 
00023     for (i=0; i< 100; i++)
00024         if (!(ptr[i]=rtl_malloc(100))){
00025             printf("Error\n");
00026             exit(-1);
00027         }
00028 
00029     for (i=0; i< 100; i++)
00030         rtl_free(ptr[i]);
00031 
00032 
00033     destroy_memory_pool(pool);
00034     printf("Test OK\n");
00035     exit(0);
00036 }
00037 
00038     
00039         

Generated on Wed Jan 14 12:58:57 2004 for RTL-lwIP-0.4 by doxygen 1.3.4