Diff for /libelwix/src/mem.c between versions 1.4.18.2 and 1.4.18.3

version 1.4.18.2, 2015/06/25 01:19:09 version 1.4.18.3, 2015/06/25 16:49:33
Line 218  mpool_malloc(mpool_t * __restrict mp, u_int size, cons Line 218  mpool_malloc(mpool_t * __restrict mp, u_int size, cons
                         return NULL;                          return NULL;
                 } else {        /* quota */                  } else {        /* quota */
                         mp->pool_quota.curr += size;                          mp->pool_quota.curr += size;
                           mp->pool_quota.real += 1 << (idx + MEM_MIN_BUCKET);
                         memset(m->alloc_mem, 0, align + 12);                          memset(m->alloc_mem, 0, align + 12);
                 }                  }
         }          }
Line 326  mpool_realloc(mpool_t * __restrict mp, void * __restri Line 327  mpool_realloc(mpool_t * __restrict mp, void * __restri
         }          }
         /* quota */          /* quota */
         mp->pool_quota.curr += (u_long) newsize - osize;          mp->pool_quota.curr += (u_long) newsize - osize;
           mp->pool_quota.real += (1 << (idx + MEM_MIN_BUCKET)) - (1 << (oidx + MEM_MIN_BUCKET));
   
         m->alloc_mem[0] = newsize / sizeof(u_int);          m->alloc_mem[0] = newsize / sizeof(u_int);
         m->alloc_mem[1] = MEM_MAGIC_START;          m->alloc_mem[1] = MEM_MAGIC_START;
Line 382  mpool_purge(mpool_t * __restrict mp, u_int atmost) Line 384  mpool_purge(mpool_t * __restrict mp, u_int atmost)
                         mp->pool_bytes.free += mem_size(m);                          mp->pool_bytes.free += mem_size(m);
                         /* quota */                          /* quota */
                         mp->pool_quota.curr -= mem_size(m);                          mp->pool_quota.curr -= mem_size(m);
                           mp->pool_quota.real -= 1 << (i + MEM_MIN_BUCKET);
   
                         if (m->alloc_mem)                          if (m->alloc_mem)
                                 free(m->alloc_mem);                                  free(m->alloc_mem);
Line 440  mpool_free(mpool_t * __restrict mp, void * __restrict  Line 443  mpool_free(mpool_t * __restrict mp, void * __restrict 
                                 mp->pool_bytes.free += mem_size(m);                                  mp->pool_bytes.free += mem_size(m);
                                 /* quota */                                  /* quota */
                                 mp->pool_quota.curr -= mem_size(m);                                  mp->pool_quota.curr -= mem_size(m);
                                   mp->pool_quota.real -= 1 << (idx + MEM_MIN_BUCKET);
   
                                 if (m->alloc_mem)                                  if (m->alloc_mem)
                                         free(m->alloc_mem);                                          free(m->alloc_mem);
Line 492  mpool_free2(mpool_t * __restrict mp, u_int size, const Line 496  mpool_free2(mpool_t * __restrict mp, u_int size, const
                                 mp->pool_bytes.free += mem_size(m);                                  mp->pool_bytes.free += mem_size(m);
                                 /* quota */                                  /* quota */
                                 mp->pool_quota.curr -= mem_size(m);                                  mp->pool_quota.curr -= mem_size(m);
                                   mp->pool_quota.real -= 1 << (idx + MEM_MIN_BUCKET);
   
                                 if (m->alloc_mem)                                  if (m->alloc_mem)
                                         free(m->alloc_mem);                                          free(m->alloc_mem);
Line 627  mpool_setquota(mpool_t * __restrict mp, u_long maxmem) Line 632  mpool_setquota(mpool_t * __restrict mp, u_long maxmem)
  * mpool_getquota() - Get memory quota   * mpool_getquota() - Get memory quota
  *   *
  * @mp = Memory pool   * @mp = Memory pool
 * @currmem = Return current memory * @currmem = Return current memory usage
  * @realmem = Return current real memory usage
  * @maxmem = Return max quota size   * @maxmem = Return max quota size
  * return: none   * return: none
  */   */
 void  void
mpool_getquota(mpool_t * __restrict mp, u_long *currmem, u_long *maxmem)mpool_getquota(mpool_t * __restrict mp, u_long *currmem, u_long *realmem, u_long *maxmem)
 {  {
         if (!mp)          if (!mp)
                 return;                  return;
   
         if (maxmem)          if (maxmem)
                 *maxmem = mp->pool_quota.max;                  *maxmem = mp->pool_quota.max;
           if (realmem)
                   *realmem = mp->pool_quota.real;
         if (currmem)          if (currmem)
                 *currmem = mp->pool_quota.curr;                  *currmem = mp->pool_quota.curr;
 }  }
Line 775  mpool_xdump() Line 783  mpool_xdump()
         printf("\n%s(%d)\n------------------------------------------------------------\n",           printf("\n%s(%d)\n------------------------------------------------------------\n", 
                         __func__, __LINE__);                          __func__, __LINE__);
         printf( " ELWIX memory pool ::\n"          printf( " ELWIX memory pool ::\n"
                "\t- quotas Current/Max = %lu/%lu\n"                "\t- quotas Current/Real/Max = %lu/%lu/%lu\n"
                 "\t- calls Alloc/Free/Cache = %lu/%lu/%lu\n"                  "\t- calls Alloc/Free/Cache = %lu/%lu/%lu\n"
                 "\t- bytes Alloc/Free/Cache = %lu/%lu/%lu\n"                  "\t- bytes Alloc/Free/Cache = %lu/%lu/%lu\n"
                 "\t- buckets :\n",                   "\t- buckets :\n", 
                elwix_mpool->pool_quota.curr, elwix_mpool->pool_quota.max,                 elwix_mpool->pool_quota.curr, elwix_mpool->pool_quota.real, elwix_mpool->pool_quota.max, 
                 elwix_mpool->pool_calls.alloc, elwix_mpool->pool_calls.free,                   elwix_mpool->pool_calls.alloc, elwix_mpool->pool_calls.free, 
                 elwix_mpool->pool_calls.cache, elwix_mpool->pool_bytes.alloc,                   elwix_mpool->pool_calls.cache, elwix_mpool->pool_bytes.alloc, 
                 elwix_mpool->pool_bytes.free, elwix_mpool->pool_bytes.cache);                  elwix_mpool->pool_bytes.free, elwix_mpool->pool_bytes.cache);

Removed from v.1.4.18.2  
changed lines
  Added in v.1.4.18.3


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