Diff for /libelwix/example/test_mem.c between versions 1.5 and 1.6

version 1.5, 2015/07/01 21:48:39 version 1.6, 2024/04/15 10:42:26
Line 4 Line 4
 #include <elwix.h>  #include <elwix.h>
   
   
void show(u_int size, u_int act, u_int inact)int show(unsigned int size, unsigned int act, unsigned int inact, void *data, unsigned int dlen)
 {  {
         if (!act && !inact)          if (!act && !inact)
                return;                return -1;
   
         if (size < 1024)          if (size < 1024)
                 printf("Statistics:: BUCKET %uB size, %u active, %u inactive\n", size, act, inact);                  printf("Statistics:: BUCKET %uB size, %u active, %u inactive\n", size, act, inact);
Line 15  void show(u_int size, u_int act, u_int inact) Line 15  void show(u_int size, u_int act, u_int inact)
                 printf("Statistics:: BUCKET %uKB size, %u active, %u inactive\n", size / 1024, act, inact);                  printf("Statistics:: BUCKET %uKB size, %u active, %u inactive\n", size / 1024, act, inact);
         else          else
                 printf("Statistics:: BUCKET %uMB size, %u active, %u inactive\n", size / (1024 * 1024), act, inact);                  printf("Statistics:: BUCKET %uMB size, %u active, %u inactive\n", size / (1024 * 1024), act, inact);
   
           return 0;
 }  }
   
 int  int
Line 64  main(int argc, char **argv) Line 66  main(int argc, char **argv)
         printf("0) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("0) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
         printf(">>> realloc 4000 to 5010 addr=%p\n", addr);          printf(">>> realloc 4000 to 5010 addr=%p\n", addr);
         addr = mpool_realloc(mp, addr, 5010, "|||||||||||||");          addr = mpool_realloc(mp, addr, 5010, "|||||||||||||");
Line 76  main(int argc, char **argv) Line 78  main(int argc, char **argv)
         printf("1) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("1) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
   
         printf(">>> free addr=%p\n", addr);          printf(">>> free addr=%p\n", addr);
Line 86  main(int argc, char **argv) Line 88  main(int argc, char **argv)
         printf("2) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("2) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
         printf(">>> purge inactive memory\n");          printf(">>> purge inactive memory\n");
         mpool_purge(mp, 0);          mpool_purge(mp, 0);
Line 97  main(int argc, char **argv) Line 99  main(int argc, char **argv)
         printf("3) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("3) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
         printf(">>> alloc new 4000\n");          printf(">>> alloc new 4000\n");
         addr = mpool_malloc(mp, 4000, "mdaaa 4000");          addr = mpool_malloc(mp, 4000, "mdaaa 4000");
Line 113  main(int argc, char **argv) Line 115  main(int argc, char **argv)
         printf("4) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("4) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
   
         printf("realloc 4000 to 100000 and to 2000000\n");          printf("realloc 4000 to 100000 and to 2000000\n");
Line 127  main(int argc, char **argv) Line 129  main(int argc, char **argv)
         printf("5) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n",           printf("5) calls.act=%lu calls.inact=%lu calls.free=%lu; bytes.act=%lu bytes.inact=%lu bytes.free=%lu;\n", 
                         mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free,                           mp->pool_calls.alloc, mp->pool_calls.cache, mp->pool_calls.free, 
                         mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);                          mp->pool_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
        mpool_statistics(mp, show);        mpool_statistics(mp, show, NULL, 0);
   
   
         mpool_dump(mp, NULL);          mpool_dump(mp, NULL);

Removed from v.1.5  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>