version 1.1.2.3, 2012/02/27 23:57:12
|
version 1.1.2.5, 2012/02/28 00:25:25
|
Line 235 mpool_malloc(mpool_t * __restrict mp, u_int size, cons
|
Line 235 mpool_malloc(mpool_t * __restrict mp, u_int size, cons
|
* return: -1 error or 0 ok |
* return: -1 error or 0 ok |
*/ |
*/ |
int |
int |
mpool_purge(mpool_t * __restrict mp, int atmost) | mpool_purge(mpool_t * __restrict mp, u_int atmost) |
{ |
{ |
register int i, cx = 0; | register int i, cx; |
struct tagAlloc *m, *tmp; |
struct tagAlloc *m, *tmp; |
|
|
if (!mp) { |
if (!mp) { |
Line 247 mpool_purge(mpool_t * __restrict mp, int atmost)
|
Line 247 mpool_purge(mpool_t * __restrict mp, int atmost)
|
|
|
mpool_lock(mp); |
mpool_lock(mp); |
|
|
for (i = 0; i < MEM_BUCKETS; i++) { | for (i = cx = 0; i < MEM_BUCKETS; cx = 0, i++) { |
TAILQ_FOREACH_SAFE(m, &mp->pool_inactive[i], alloc_node, tmp) { |
TAILQ_FOREACH_SAFE(m, &mp->pool_inactive[i], alloc_node, tmp) { |
/* count barrier for purge */ | /* barrier for purge */ |
if (cx++ < atmost) | if (cx < atmost) { |
| cx++; |
continue; |
continue; |
|
} |
|
|
TAILQ_REMOVE(&mp->pool_inactive[i], m, alloc_node); |
TAILQ_REMOVE(&mp->pool_inactive[i], m, alloc_node); |
/* statistics */ |
/* statistics */ |
Line 296 mpool_free(mpool_t * __restrict mp, void * __restrict
|
Line 298 mpool_free(mpool_t * __restrict mp, void * __restrict
|
sess_SetErr(EFAULT, "Corrupted memory address"); |
sess_SetErr(EFAULT, "Corrupted memory address"); |
return -2; |
return -2; |
} else |
} else |
idx = BucketIndex(((u_int*)data)[-2]); | idx = BucketIndex(((u_int*)data)[-2] * sizeof(u_int)); |
|
|
mpool_lock(mp); |
mpool_lock(mp); |
TAILQ_FOREACH(m, &mp->pool_active[idx], alloc_node) |
TAILQ_FOREACH(m, &mp->pool_active[idx], alloc_node) |