"Fossies" - the Fresh Open Source Software Archive

Member "FunctionCheck-3.2.0/test/simple_test_mem.c" (26 May 2012, 727 Bytes) of package /linux/privat/old/FunctionCheck-3.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 
    4 void * my_malloc(int size)
    5 {
    6     return malloc(size);
    7 }
    8 
    9 void * _my_realloc(void *ptr, int size)
   10 {
   11     return realloc(ptr, size);
   12 }
   13 
   14 void * my_realloc(void *ptr, int size)
   15 {
   16     return _my_realloc(ptr, size);
   17 }
   18 
   19 int main(int argc, char*argv[])
   20 {
   21     void *p1, *p2, *p3;
   22 
   23     printf("starting...\n");
   24 
   25     p1 = my_malloc(64);
   26     printf("p1=%p (64)\n", p1);
   27     p2 = my_malloc(128);
   28     printf("p2=%p (128)\n", p2);
   29 
   30     p1 = my_realloc(p1, 32);
   31     printf("p1 -> %p (32)\n", p1);
   32     p2 = my_realloc(p2, 256);
   33     printf("p2 -> %p (256)\n", p2);
   34 
   35     p3 = my_malloc(16);
   36     printf("p3=%p (16)\n", p3);
   37 
   38     free(p2);
   39     printf("free p2\n");
   40 
   41     printf("the end.\n");
   42 
   43     return 0;
   44 }