Diff for /libelwix/example/test_mem.c between versions 1.4 and 1.5.78.1

version 1.4, 2015/06/25 17:53:49 version 1.5.78.1, 2024/04/15 09:50:57
Line 43  main(int argc, char **argv) Line 43  main(int argc, char **argv)
         printf("___current=%lu\n", curr);          printf("___current=%lu\n", curr);
         */          */
   
           printf(">>> get 3 allocs\n");
         for (i = 0; i < 3; i++) {          for (i = 0; i < 3; i++) {
                 addr = mpool_malloc(mp, 4000, "mdaaa 4000");                  addr = mpool_malloc(mp, 4000, "mdaaa 4000");
                 if (!addr) {                  if (!addr) {
Line 63  main(int argc, char **argv) Line 64  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);
         addr = mpool_realloc(mp, addr, 5010, "|||||||||||||");          addr = mpool_realloc(mp, addr, 5010, "|||||||||||||");
         if (!addr)          if (!addr)
                 printf("Error:: #%d - %s\n", elwix_GetErrno(), elwix_GetError());                  printf("Error:: #%d - %s\n", elwix_GetErrno(), elwix_GetError());
Line 74  main(int argc, char **argv) Line 76  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);
         if (addr)          if (addr)
                 mpool_free(mp, addr, 0);                  mpool_free(mp, addr, 0);
   
         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");
         mpool_purge(mp, 0);          mpool_purge(mp, 0);
   
         mpool_getquota(mp, &curr, &real, NULL);          mpool_getquota(mp, &curr, &real, NULL);
Line 93  main(int argc, char **argv) Line 97  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");
         addr = mpool_malloc(mp, 4000, "mdaaa 4000");          addr = mpool_malloc(mp, 4000, "mdaaa 4000");
         if (!addr) {          if (!addr) {
                 printf("Error:: #%d - %s\n", elwix_GetErrno(), elwix_GetError());                  printf("Error:: #%d - %s\n", elwix_GetErrno(), elwix_GetError());
Line 102  main(int argc, char **argv) Line 107  main(int argc, char **argv)
                 return 2;                  return 2;
         }          }
         printf("addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));          printf("addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
           printf(">>> and free new 4000 addr=%p\n", addr);
         mpool_free(mp, addr, 0);          mpool_free(mp, addr, 0);
   
         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");
         addr = mpool_malloc(mp, 4000, "mdaaa 4000");
         printf("malloc addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
         addr = mpool_realloc(mp, addr, 100000, "ohche");
         printf("realloc addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
         addr = mpool_realloc(mp, addr, 2000000, NULL);
         printf("realloc addr=%p chkaddr=%d addr_size=%d\n", addr, mpool_chkaddr(addr), mpool_getsizebyaddr(addr));
         mpool_free(mp, addr, 0);
         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_bytes.alloc, mp->pool_bytes.cache, mp->pool_bytes.free);
         mpool_statistics(mp, show, NULL, 0);
 
 
         mpool_dump(mp, NULL);
         mpool_destroy(&mp);          mpool_destroy(&mp);
         return 0;          return 0;
 }  }

Removed from v.1.4  
changed lines
  Added in v.1.5.78.1


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